Skip to content

Commit

Permalink
Proper multi-output callback exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Oct 26, 2018
1 parent eb8e1c5 commit f63ff10
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit f63ff10

Please sign in to comment.