-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: change return error.respond() to raise #6780
Conversation
Codecov Report
@@ Coverage Diff @@
## development #6780 +/- ##
============================================
Coverage 66.38% 66.38%
============================================
Files 313 313
Lines 15360 15360
============================================
Hits 10197 10197
Misses 5163 5163 Continue to review full report at Codecov.
|
app/instance.py
Outdated
}), | ||
429, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you changing this?
app/instance.py
Outdated
@@ -269,5 +270,17 @@ def ratelimit_handler(error): | |||
}) | |||
|
|||
|
|||
@app.errorhandler(HTTPException) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to handle any HTTPException, we want to handle our custom exceptions
app/instance.py
Outdated
@@ -6,6 +6,7 @@ | |||
|
|||
import sys | |||
from flask import Flask, json, make_response | |||
from werkzeug.exceptions import HTTPException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'werkzeug.exceptions.HTTPException' imported but unused
Is that what we want @iamareebjamal? |
app/instance.py
Outdated
403, | ||
{ | ||
'Content-Type': 'application/vnd.api+json' | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you kindly please tell me @iamareebjamal what changes I need to do? I am registering error handler just as I did before for 429.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can read the issue again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
Please review my changes @iamareebjamal |
It's still wrong. Read the issue again |
Please again check @iamareebjamal. Sorry for bothering you |
Still wrong |
Still wrong. Read my 2 comments carefully |
Please check this @iamareebjamal ! |
app/api/helpers/exceptions.py
Outdated
|
||
|
||
class UnprocessableEntity(JsonApiException): | ||
class UnprocessableEntity(JsonApiException, ErrorResponse): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove ErrorResponse
Please review again @iamareebjamal |
Kindly please check @iamareebjamal |
app/api/helpers/exceptions.py
Outdated
@@ -10,7 +11,7 @@ class UnprocessableEntity(JsonApiException): | |||
status = 422 | |||
|
|||
|
|||
class ConflictException(JsonApiException): | |||
class ConflictException(JsonApiException, ErrorResponse): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove ErrorResponse
I have made the required changes @iamareebjamal |
app/api/helpers/exceptions.py
Outdated
@@ -1,4 +1,5 @@ | |||
from flask_rest_jsonapi.exceptions import JsonApiException | |||
from app.api.helpers.errors import ErrorResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'app.api.helpers.errors.ErrorResponse' imported but unused
return ForbiddenError( | ||
{'source': ''}, 'Super admin access is required' | ||
).respond() | ||
raise ForbiddenError({'source': ''}, 'Super admin access is required') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
@@ -27,15 +27,15 @@ def is_super_admin(view, view_args, view_kwargs, *args, **kwargs): | |||
""" | |||
user = current_user | |||
if not user.is_super_admin: | |||
return ForbiddenError({'source': ''}, 'Super admin access is required').respond() | |||
raise ForbiddenError({'source': ''}, 'Super admin access is required') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
Issues
======
+ Solved 2
Clones removed
==============
+ app/api/event_invoices.py -1
+ app/api/helpers/permission_manager.py -2
+ app/api/orders.py -1
+ app/api/role_invites.py -2
See the complete overview on Codacy |
Finally, after 48 commits for a small change |
This pull request fixes 6 alerts when merging ab008c5 into 40a1f28 - view on LGTM.com fixed alerts:
|
Fixes #6665
Checklist
development
branch.