-
Notifications
You must be signed in to change notification settings - Fork 192
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
[bug] unknown categories are not handled by an error #669
Labels
Comments
Probably could use http://flask.pocoo.org/docs/0.10/api/#flask.Blueprint.app_errorhandler |
food for thoughts from http://blog.luisrei.com/articles/flaskrest.html @app.errorhandler(404)
def not_found(error=None):
message = {
'status': 404,
'message': 'Not Found: ' + request.url,
}
resp = jsonify(message)
resp.status_code = 404
return resp
@app.route('/users/<userid>', methods = ['GET'])
def api_users(userid):
users = {'1':'john', '2':'steve', '3':'bill'}
if userid in users:
return jsonify({userid:users[userid]})
else:
return not_found() |
@karlcow the not_found solution looks good. |
And my comment is on the wrong bug. 👊 |
karlcow
added a commit
to karlcow/webcompat.com
that referenced
this issue
Aug 14, 2015
Should also be useful for webcompat#667
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@api.route('/issues/search/<issue_category>')
in https://github.com/webcompat/webcompat.com/blob/master/webcompat/api/endpoints.py#L194-L213
We deal with category list and if not know we say new but if none of that we return something without being defined in the first place, which creates the error message:
ooops, my bad.
The text was updated successfully, but these errors were encountered: