Skip to content

Commit

Permalink
Merge pull request #171 from bento-platform/feat/responses/new-errors
Browse files Browse the repository at this point in the history
feat(responses): add new error responses
  • Loading branch information
davidlougheed authored Jan 3, 2024
2 parents 8584301 + a40064c commit c77331d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bento_lib/package.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = bento_lib
version = 11.1.2
version = 11.2.0
authors = David Lougheed, Paul Pillot
author_emails = [email protected], [email protected]
6 changes: 6 additions & 0 deletions bento_lib/responses/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"unauthorized_error",
"forbidden_error",
"not_found_error",
"not_acceptable_error",
"request_timeout_error",
"range_not_satisfiable_error",

"internal_server_error",
"not_implemented_error",
Expand Down Expand Up @@ -87,6 +90,9 @@ def http_error(
unauthorized_error = _e(401)
forbidden_error = _e(403)
not_found_error = _e(404)
not_acceptable_error = _e(406)
request_timeout_error = _e(408)
range_not_satisfiable_error = _e(416)

internal_server_error = _e(500)
not_implemented_error = _e(501)
9 changes: 8 additions & 1 deletion bento_lib/responses/flask_errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import sys
import traceback

Expand All @@ -19,6 +20,9 @@
"flask_unauthorized_error",
"flask_forbidden_error",
"flask_not_found_error",
"flask_not_acceptable_error",
"flask_request_timeout_error",
"flask_range_not_satisfiable_error",

"flask_internal_server_error",
"flask_not_implemented_error",
Expand All @@ -37,7 +41,7 @@ def flask_error_wrap_with_traceback(fn: Callable, *args, **kwargs) -> Callable:

service_name = kwargs.pop("service_name", "Bento Service")

logger = kwargs.pop("logger", None)
logger: logging.Logger | None = kwargs.pop("logger", None)
authz: MarkAuthzDoneType | None = kwargs.pop("authz", None)

def handle_error(e):
Expand Down Expand Up @@ -84,6 +88,9 @@ def _flask_error(code: int) -> Callable:
flask_unauthorized_error = _flask_error(401)
flask_forbidden_error = _flask_error(403)
flask_not_found_error = _flask_error(404)
flask_not_acceptable_error = _flask_error(406)
flask_request_timeout_error = _flask_error(408)
flask_range_not_satisfiable_error = _flask_error(416)

flask_internal_server_error = _flask_error(500)
flask_not_implemented_error = _flask_error(501)

0 comments on commit c77331d

Please sign in to comment.