-
Notifications
You must be signed in to change notification settings - Fork 106
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
Remove flask dependency api layer #373
Conversation
Starting demo at: http://snapcraft.io-pr-373.run.demo.haus/ |
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.
Yay Season 2 👍 thanks @tbille
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.
some comments, post-merge :-/
"JSON decoding failed: ", | ||
str(decode_error), | ||
]) | ||
raise InvalidResponseContent(error_message) |
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.
Nitpicking on style, the string-joining looks strange:
error_message = 'JSON decoding failed: {}'.format(decode_error)
]) | ||
raise InvalidResponseContent(error_message) | ||
|
||
if details_response.status_code != 200: |
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.
The store API uses other 2xx status and they should be treated as success.
|
||
if details_response.status_code != 200: | ||
if 'error_list' in details: | ||
api_error_exception = ApiErrorResponse("Error list") |
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 might get some expiration from https://git.launchpad.net/snapdevicegw/tree/snapdevicegw/exceptions.py and have a chain of exceptions that would treat the API errors internally, APIError(error_response)
if api_error_exception.errors: | ||
flask.abort(api_error_exception.status, api_error_exception.errors) | ||
else: | ||
flask.abort(api_error_exception.status, ["Unknown error"]) |
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.
It doesn't seem to be a good idea to blindly 'leak' snap-details error status to you own application, nor leaking bad-json responses to ugly 500s to the app users. Wouldn't it be possible to tolerate errors and carry on with details = {...}
?
Refactoto S02E01 - The first Endpoint
Summary
QA
./run
./run test