From be305f0faf24db1a2f3c58c7afb94a0c4d529e05 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 29 Oct 2020 10:42:28 +0100 Subject: [PATCH 1/3] Improve error message --- dash/dash.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dash/dash.py b/dash/dash.py index 71ae894a24..68ebcfe3fb 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -1068,7 +1068,10 @@ def dispatch(self): args = inputs_to_vals(inputs + state) - func = self.callback_map[output]["callback"] + try: + func = self.callback_map[output]["callback"] + except KeyError: + raise KeyError("Callback not found, maybe you forgot to prepend the '@'?") response.set_data(func(*args, outputs_list=outputs_list)) return response From aa7c669de8942b1ada5f967c03cfe0fa96a08d3a Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 29 Oct 2020 10:50:35 +0100 Subject: [PATCH 2/3] add to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d07758ebe9..d1df77b5ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Fixed - [#1434](https://github.com/plotly/dash/pull/1434) Fix [#1432](https://github.com/plotly/dash/issues/1432) for Julia to import non-core component packages without possible errors. +### Changed +- [#1448](https://github.com/plotly/dash/pull/1448) Provide a hint in the callback error when the user forgot to make `app.callback(...)` a decorator. + ## [1.16.3] - 2020-10-07 ### Fixed - [#1426](https://github.com/plotly/dash/pull/1426) Fix a regression caused by `flask-compress==1.6.0` causing performance degradation on server requests From 22e3a502575b4fa49ec55afd211a926f4f13a203 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 29 Oct 2020 16:01:26 +0100 Subject: [PATCH 3/3] include output id in error message --- dash/dash.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dash/dash.py b/dash/dash.py index 68ebcfe3fb..54fc4c9be5 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -1071,7 +1071,8 @@ def dispatch(self): try: func = self.callback_map[output]["callback"] except KeyError: - raise KeyError("Callback not found, maybe you forgot to prepend the '@'?") + msg = "Callback function not found for output '{}', perhaps you forgot to prepend the '@'?" + raise KeyError(msg.format(output)) response.set_data(func(*args, outputs_list=outputs_list)) return response