Replies: 1 comment
-
Since I think that a NotNormalizableValueException and not a TypeError should be thrown here, I created a pull request: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all,
for my API I deserialize my requests with the Symfony serializer and then validate them with the validator. What is the best way to deal with TypeErrors that don't make it to the validator, but fail during deserialisation?
For example, I have a \DateTime field in my DTO. If something other than a string is supplied, I get a TypeError: DateTime::createFromFormat(): Argument ($datetime) must be of type string, array given. I can't even catch this with a try/catch around my deserialisation. I'm already using COLLECT_DENORMALIZATION_ERRORS and catching both PartialDenormalizationException and general exceptions.
Currently, I'm trying to catch the KernelException and build a reasonably useful error message out of it. At this point, however, I no longer have any information about which field the error occurred in.
How do you deal with this problem, or do you have any advice for me?
Beta Was this translation helpful? Give feedback.
All reactions