Skip to content

Conversation

gsfr
Copy link
Member

@gsfr gsfr commented Feb 25, 2016

raise exceptions instead (caught by base.RequestHandler.handle_exception)

partially addresses #66

raise exceptions instead (catched by base.RequestHandler.handle_exception)
@gsfr
Copy link
Member Author

gsfr commented Feb 25, 2016

LGTM, btw.

Let's discuss the exception type before we merge.

_validate_json(payload, _schema, resolver_input)
except jsonschema.ValidationError as e:
handler.abort(400, str(e))
raise webapp2.exc.HTTPBadRequest(str(e))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having this be webapp2-aware would actually be nicer, wouldn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah probably the best thing to do is to catch the ValidationError in the handler calling the method

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a little more encapsulation. Your code shouldn't expose its internals, such as its use of jsonschema. You should rather define a ValidationException so that I can then say except validators.ValidationException.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed a new commit. Added two exceptions to distinguish when the exception is critical(mongo schema validations).

gsfr pushed a commit that referenced this pull request Feb 25, 2016
gsfr pushed a commit that referenced this pull request Feb 25, 2016
@rentzso rentzso force-pushed the reduce-http-awareness branch from d0186bb to ea97a70 Compare February 25, 2016 22:50
@gsfr
Copy link
Member Author

gsfr commented Feb 25, 2016

👍

@kofalt
Copy link
Contributor

kofalt commented Feb 25, 2016

LGTM, merge as desired

gsfr pushed a commit that referenced this pull request Feb 25, 2016
Stop using handler.abort in validators
@gsfr gsfr merged commit d5f9db2 into master Feb 25, 2016
@gsfr gsfr deleted the reduce-http-awareness branch February 25, 2016 23:24
gsfr pushed a commit that referenced this pull request Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants