server/rest: fix reporting parameter type errors
This commit is contained in:
parent
ff7bbbdd8a
commit
e89a086d58
1 changed files with 29 additions and 27 deletions
|
@ -86,6 +86,7 @@ def _create_context(env):
|
||||||
|
|
||||||
|
|
||||||
def application(env, start_response):
|
def application(env, start_response):
|
||||||
|
try:
|
||||||
try:
|
try:
|
||||||
ctx = _create_context(env)
|
ctx = _create_context(env)
|
||||||
if 'application/json' not in ctx.get_header('Accept'):
|
if 'application/json' not in ctx.get_header('Accept'):
|
||||||
|
@ -105,11 +106,6 @@ def application(env, start_response):
|
||||||
handler = allowed_methods[ctx.method]
|
handler = allowed_methods[ctx.method]
|
||||||
try:
|
try:
|
||||||
response = handler(ctx, match.groupdict())
|
response = handler(ctx, match.groupdict())
|
||||||
except Exception as ex:
|
|
||||||
for exception_type, handler in errors.error_handlers.items():
|
|
||||||
if isinstance(ex, exception_type):
|
|
||||||
handler(ex)
|
|
||||||
raise
|
|
||||||
finally:
|
finally:
|
||||||
for hook in middleware.post_hooks:
|
for hook in middleware.post_hooks:
|
||||||
hook(ctx)
|
hook(ctx)
|
||||||
|
@ -120,6 +116,12 @@ def application(env, start_response):
|
||||||
raise errors.HttpNotFound(
|
raise errors.HttpNotFound(
|
||||||
'Requested path ' + ctx.url + ' was not found.')
|
'Requested path ' + ctx.url + ' was not found.')
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
for exception_type, handler in errors.error_handlers.items():
|
||||||
|
if isinstance(ex, exception_type):
|
||||||
|
handler(ex)
|
||||||
|
raise
|
||||||
|
|
||||||
except errors.BaseHttpError as ex:
|
except errors.BaseHttpError as ex:
|
||||||
start_response(
|
start_response(
|
||||||
'%d %s' % (ex.code, ex.reason),
|
'%d %s' % (ex.code, ex.reason),
|
||||||
|
|
Loading…
Reference in a new issue