Skip to content

Commit

Permalink
added PreventUpdate exception and attached handler to Flask server
Browse files Browse the repository at this point in the history
  • Loading branch information
Ned Letcher authored and chriddyp committed Jan 19, 2018
1 parent 3085796 commit ad92fa3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dash/dash.py
@@ -1,3 +1,4 @@
import sys
import collections
import importlib
import json
Expand Down Expand Up @@ -53,6 +54,12 @@ def __init__(
# gzip
Compress(self.server)

@self.server.errorhandler(exceptions.PreventUpdate)
def handle_error(error):
"""Handle a halted callback and return an empty 204 response"""
print(error, file=sys.stderr)
return ('', 204)

# static files from the packages
self.css = Css()
self.scripts = Scripts()
Expand Down
3 changes: 3 additions & 0 deletions dash/exceptions.py
Expand Up @@ -40,3 +40,6 @@ class IDsCantContainPeriods(CallbackException):

class CantHaveMultipleOutputs(CallbackException):
pass

class PreventUpdate(CallbackException):
pass

0 comments on commit ad92fa3

Please sign in to comment.