You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have this custom exception handler for PermissionDenied errors:
@api.exception_handler(PermissionDenied)
def permission_error(request, exc):
if 'team_id' in request.resolver_match.captured_kwargs.keys():
message = "You do not have access to this team."
else:
message = "Forbidden."
return api.create_response(
request,
{"detail": message},
status=403,
)
I'd like to customize the error messages based on information in the request. But using the TestClient, the request is a Mock instance, so I get an TypeError: argument of type 'Mock' is not iterable when trying to access the request's captured kwargs. Is there a way around this?
The text was updated successfully, but these errors were encountered:
I have this custom exception handler for PermissionDenied errors:
I'd like to customize the error messages based on information in the request. But using the TestClient, the request is a
Mock
instance, so I get anTypeError: argument of type 'Mock' is not iterable
when trying to access the request's captured kwargs. Is there a way around this?The text was updated successfully, but these errors were encountered: