You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Really tidy little CSV parser, my only issue is if I'm wanting to catch errors and return my own messaging to users, I'd currently have to catch the RuntimeException and then check the message to determine what kind of failure it was.
I think it might be nicer to throw things like InvalidRecordException or StreamNotSeekableException which all extend a common ParserException which can then extend RuntimeException for backwards compatibility.
Happy to do a PR if you think it's a good idea, and thanks for publishing this!
The text was updated successfully, but these errors were encountered:
nickma42
changed the title
Ambiguous exceptions should be replaced with more specific exceptions
Generic exceptions should be replaced with more specific exceptions
Oct 16, 2018
And another thought about being able to access the actual validation errors if a record fails validation; at the moment you just check passes() on the Laravel validator here:
Maybe the Validator class could mirror the behavior of the validate() method of the underlying Laravel validator instead, which throws a ValidationException with access to the validator so you can pull out the validation messages?
and parseFailed can then re-throw the exception if throws is enabled. Anything upstream catching those ValidationException exceptions can just do $exception->getValidator() or similar to get the Validator and access the error messages.
Really tidy little CSV parser, my only issue is if I'm wanting to catch errors and return my own messaging to users, I'd currently have to catch the
RuntimeException
and then check the message to determine what kind of failure it was.I think it might be nicer to throw things like
InvalidRecordException
orStreamNotSeekableException
which all extend a commonParserException
which can then extendRuntimeException
for backwards compatibility.Happy to do a PR if you think it's a good idea, and thanks for publishing this!
The text was updated successfully, but these errors were encountered: