Skip to content

Commit dc53205

Browse files
committedJun 20, 2024
Load error views from strings
1 parent 4d56944 commit dc53205

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

Diff for: ‎bolt/bolt/internal/handlers/exception.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from bolt.http.multipartparser import MultiPartParserError
1515
from bolt.logs import log_response
1616
from bolt.runtime import settings
17+
from bolt.utils.module_loading import import_string
1718
from bolt.views.errors import ErrorView
1819

1920

@@ -132,7 +133,11 @@ def handle_uncaught_exception():
132133
def get_error_view(status_code):
133134
views_by_status = settings.HTTP_ERROR_VIEWS
134135
if status_code in views_by_status:
135-
return views_by_status[status_code].as_view()
136+
view = views_by_status[status_code]
137+
if isinstance(view, str):
138+
# Import the view if it's a string
139+
view = import_string(view)
140+
return view.as_view()
136141

137142
# Create a standard view for any other status code
138143
return ErrorView.as_view(status_code=status_code)

0 commit comments

Comments
 (0)
Please sign in to comment.