Skip to content

Commit 3f00325

Browse files
committed
Take the output value from the error handler only if not None.
1 parent 30d6f11 commit 3f00325

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

dash/_callback.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,17 @@ def add_context(*args, **kwargs):
463463
f"An error occurred inside a long callback: {error['msg']}\n{error['tb']}"
464464
)
465465
if error_handler:
466-
error_handler(exc)
467-
output_value = NoUpdate()
466+
output_value = error_handler(exc)
467+
468+
if output_value is None:
469+
output_value = NoUpdate()
468470
# set_props from the error handler uses the original ctx
469471
# instead of manager.get_updated_props since it runs in the
470472
# request process.
471-
has_update = _set_side_update(callback_ctx, response)
473+
has_update = (
474+
_set_side_update(callback_ctx, response)
475+
or output_value is not None
476+
)
472477
else:
473478
raise exc
474479

@@ -495,11 +500,14 @@ def add_context(*args, **kwargs):
495500
raise err
496501
except Exception as err: # pylint: disable=broad-exception-caught
497502
if error_handler:
498-
error_handler(err)
499-
if not multi:
500-
output_value = NoUpdate()
501-
else:
502-
output_value = [NoUpdate for _ in output_spec]
503+
output_value = error_handler(err)
504+
505+
# If the error returns nothing, automatically puts NoUpdate for response.
506+
if output_value is None:
507+
if not multi:
508+
output_value = NoUpdate()
509+
else:
510+
output_value = [NoUpdate for _ in output_spec]
503511
else:
504512
raise err
505513

0 commit comments

Comments
 (0)