cerberus icon indicating copy to clipboard operation
cerberus copied to clipboard

Proposal: make missing or bad-formatted document not raise an exception

Open funkyfuture opened this issue 10 years ago • 3 comments

as i'm currently refactoring the error-handling, i stumbled across the circumstance that a missing document or one that is not a mapping will raise an exception.

however cerberus is propagated to be non-blocking and both could be handled via the usual error-mechanism.

though it will require client-code to be refactored, not raising an error would streamline error-handling. as a benefit validating objects from an iterable wouldn't be interrupted (eg. in list comprehensions).

are there real-world situations known where the client code couldn't handle errors outside an exception?

the same could be discussed for bad schemas; but i see a point here to escalate.

funkyfuture avatar Sep 07 '15 00:09 funkyfuture

Well non-blocking refers to document validation process. Those exception are raised when the document is not there or it is in the wrong format so I believe they are still appropriate. Also as you say, this would need amending of client code. Eve for example, relies on the exception being raised in order to inform the user that something is wrong with endpoint validation settings (lazy way out). I think we are fine with raising the exception when document is missing (it is in fact a show stopper). I do like the option to validate objects from an iterable though.

nicolaiarocci avatar Sep 08 '15 06:09 nicolaiarocci

i'd say the document validation process starts upon calling Validator.validate.

changing the behaviour could be an opt-in. either by adding a further validator-option (meh) or a subclass (would be useful if there are further iterating-validation specifics to cover).

but i see not much effort in amending client code, so it could be postponed to the next major release.

funkyfuture avatar Sep 09 '15 11:09 funkyfuture

also adding the 2.0 milestone here b/c this needs decision before its release.

funkyfuture avatar May 06 '19 20:05 funkyfuture

closing this issue as there are currently no intentions to continue a next major release.

funkyfuture avatar Jul 23 '23 12:07 funkyfuture