Replies: 6 comments
-
Actually the exception messages here sound exactly correct to me. |
Beta Was this translation helpful? Give feedback.
-
But I think no. 3 should be fixed 😄 |
Beta Was this translation helpful? Give feedback.
-
The problem mentioned in the SO question really is more complicated. I still believe we need to have better support for DTOs / resource representation classes by having a 2-pass process: #2053 |
Beta Was this translation helpful? Give feedback.
-
@teohhanhui I think the issue I personally had with errors 1 and 2, is that the error made no sense in the context of what was going on. I had no idea why a route was even trying to be generated for my Model. It wasn't till i learned that API platform uses the symfony router to generate the IRI, did the error kind of make sense. I think if the error included a clause like |
Beta Was this translation helpful? Give feedback.
-
Sure, I guess we could catch the exception and wrap it. :) |
Beta Was this translation helpful? Give feedback.
-
Hi, my solution to avoid declaring a /edit: whooops wrong issue leaving the comment anyway just in case. |
Beta Was this translation helpful? Give feedback.
-
The default IRI Converter uses the symfony router to handle the generation of the IRI values per entity. If there are any issues with IRI generation or lookup by IRI, the exceptions that get thrown are hard to understand/misleading because the errors will be associated with Routing and not with denormalizing an entity or fetching an entity by an IRI.
Here are a few examples of some scenarios that generate errors with the IRI Converter and have confusing error messages:
You can get errors 1 and 2 if API Platform tries to serialize an entity that does not have a GET item/collection operation defined which is common when working with DTO's. See this Stackoverflow Post
Error 3 can show up if you pass in malformed IRI value for a relationship entity.
I think a possible solution for friendlier error messages would be to catch exceptions thrown in the in the normalizers and give error messages that are closer to the actual problem.
Beta Was this translation helpful? Give feedback.
All reactions