From f63ff102407a6a7e90674927a64cd7af7c8d2443 Mon Sep 17 00:00:00 2001 From: Philippe Duval Date: Fri, 26 Oct 2018 11:20:27 -0400 Subject: [PATCH] Proper multi-output callback exceptions. --- dash/dash.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/dash/dash.py b/dash/dash.py index 7241f03f4d..167dad01c7 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -857,13 +857,23 @@ def add_context(*args, **kwargs): output_value = func(*args, **kwargs) if multi: if not isinstance(output_value, (list, tuple)): - raise Exception('Invalid output value') + raise exceptions.InvalidCallbackReturnValue( + 'The callback {} is a multi-output.\n' + 'Expected the output type to be a list' + ' or tuple but got {}.'.format( + callback_id, repr(output_value) + ) + ) if not len(output_value) == len(output): - raise Exception( - 'Invalid number of output values.' + raise exceptions.InvalidCallbackReturnValue( + 'Invalid number of output values for {}.\n' ' Expected {} got {}'.format( - len(output), len(output_value))) + callback_id, + len(output), + len(output_value) + ) + ) props = collections.defaultdict(dict) for i, out in enumerate(output):