Skip to content
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

fix: include code in the error response body #44

Merged
merged 2 commits into from
Aug 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion testbench/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ def __init__(self, msg, code):
self.code = code

def as_response(self):
return flask.make_response(flask.jsonify(self.msg), self.code)
# Include both code and message so we follow the schema outlined in
# https://cloud.google.com/apis/design/errors#error_model and some
# clients depend on code being specified, otherwise behavior is
# undefined.
return flask.make_response(
flask.jsonify(code=self.code, message=self.msg), self.code
)

@staticmethod
def handler(ex):
Expand Down