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

Subclass SchemaError for default errors such as 'Wrong keys', 'Missing keys' 'Wrong Type' #111

Closed
bernalrs opened this issue Jul 27, 2016 · 4 comments

Comments

@bernalrs
Copy link
Contributor

I would like to suggest a simple change that would see the introduction of some new Error/Exception derived from SchemaError which would serve the purpose.

As of verson 0.6.1:

  1. raise SchemaError('Wrong keys %s in %r' % (s_wrong_keys, data), e.format(data) if e else None)
  2. raise SchemaError('Missing keys: ' + s_missing_keys, e)
  3. SchemaError('%r should be instance of %r' % (data, s.__name__), e.format(data) if e else None)

into

  1. class SchemaWrongKeyError(SchemaError):
  2. class SchemaMissingkeysError(SchemaError):
  3. class SchemaUnexpectedTypeError(SchemaError)

Thanks

@skorokithakis
Copy link
Collaborator

As long as these exceptions inherit from SchemaError, this looks good to me. Is there any possibility that something could be adversely impacted?

@bernalrs
Copy link
Contributor Author

As long as we do not change the error message we should be OK. This should allow developers to catch specific exception and re-throw them when using this library in the application code.

@bernalrs
Copy link
Contributor Author

Might be worth adding these new type in the README.md do you agree ?

@skorokithakis
Copy link
Collaborator

Yes :( I forgot about that and already released 0.6.2... Would you like to do the honours of documenting the errors?

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

No branches or pull requests

2 participants