diff options
author | W. Trevor King <wking@tremily.us> | 2012-10-28 20:20:27 -0400 |
---|---|---|
committer | W. Trevor King <wking@tremily.us> | 2012-10-28 20:24:22 -0400 |
commit | ea9cc6e140481a3b804d464f1f49b1b57952fdcb (patch) | |
tree | 558bde19ce1f0be3c49b629415fcefdf481c3034 /libbe/util/wsgi.py | |
parent | 71e53cb9db2755940340ccd73f542e48ae27a064 (diff) | |
download | bugseverywhere-ea9cc6e140481a3b804d464f1f49b1b57952fdcb.tar.gz |
util:wsgi: handle all dispatch() exceptions in BEExceptionApp
This brings BEExceptionApp into closer agreement with
libbe.ui.command_line.dispatch(), and avoids having the server go down
when a user submits a silly command.
Diffstat (limited to 'libbe/util/wsgi.py')
-rw-r--r-- | libbe/util/wsgi.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/libbe/util/wsgi.py b/libbe/util/wsgi.py index cd4fbed..8f407e4 100644 --- a/libbe/util/wsgi.py +++ b/libbe/util/wsgi.py @@ -58,14 +58,13 @@ try: except ImportError: OpenSSL = None - -import libbe.util.encoding -import libbe.util.http -import libbe.util.id import libbe.command import libbe.command.base import libbe.command.util import libbe.storage +import libbe.util.encoding +import libbe.util.http +import libbe.util.id if libbe.TESTING == True: @@ -316,12 +315,19 @@ class BEExceptionApp (WSGI_Middleware): raise libbe.util.wsgi.HandlerError(403, 'Read permission denied') except libbe.storage.NotWriteable as e: raise libbe.util.wsgi.HandlerError(403, 'Write permission denied') - except libbe.storage.InvalidID as e: - raise libbe.util.wsgi.HandlerError( - libbe.util.http.HTTP_USER_ERROR, 'InvalidID {}'.format(e)) - except libbe.util.id.NoIDMatches as e: + except (libbe.command.UsageError, + libbe.command.UserError, + OSError, + libbe.storage.ConnectionError, + libbe.util.http.HTTPError, + libbe.util.id.MultipleIDMatches, + libbe.util.id.NoIDMatches, + libbe.util.id.InvalidIDStructure, + libbe.storage.InvalidID, + ) as e: + msg = '{} {}'.format(type(e).__name__, format(e)) raise libbe.util.wsgi.HandlerError( - libbe.util.http.HTTP_USER_ERROR, 'NoIDMatches {}'.format(e)) + libbe.util.http.HTTP_USER_ERROR, msg) class UppercaseHeaderApp (WSGI_Middleware): |