Closed (fixed)
Project:
JSON:API
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
3 Oct 2016 at 08:10 UTC
Updated:
28 Oct 2016 at 14:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sutharsan commentedAttached patch is to illustrate the solution direction I propose. It is not working yet.
Comment #3
e0ipsoThis is fantastic! I like where this is going, we should explore more.
Comment #4
sutharsan commentedFirst working version. Time for writing tests...
Comment #5
sutharsan commentedComment #8
e0ipsoPlease use the shorthand syntax
[]All JSONAPI routes have an option flag called
_is_jsonapithat we may want to check as well.Comment #9
e0ipsoAlso, there are some tests failing (uninitialized container?).
We will also need testing for the new subscriber. We already have test coverage for the exception serialization somewhere else, but we'll need to test the other stuff as well. Hopefully a unit test that checks the expected output for:
onExceptionappliesComment #10
e0ipsoComment #11
sutharsan commentedComments from #8 addressed.
Comment #12
e0ipsoThanks @Sutharsan. It seems that the actual patch is missing, there is only the interdiff :-P
Comment #13
wim leers+1 for the changes to
RequestHandler.-1 for the addition of that new exception event subscriber.
\Drupal\serialization\EventSubscriber\DefaultExceptionSubscriberalready does that, in a more generic way.Comment #14
e0ipsoTaking this into an slightly different direction.
Comment #15
e0ipsoComment #17
e0ipsoFixed and merged. I decided to grant authorship to Sutharsan, because he is awesome and did a great job reporting this and taking it to near completion.
Thanks all!
Comment #18
wim leersWhy do you need this class?
Why does it need to run so early?
Comment #19
e0ipsoThanks for the review Wim. I should've mentioned you in the commit credits as well. Shame on me.
Because the
\Drupal\serialization\EventSubscriber\DefaultExceptionSubscriberis opinionated on how I have to normalize my exceptions in thesetEventResponse. Serializing an array['message' => $exception->getMessage()]is not good enough for jsonapi.I think that core should ship with HttpException normalizers that do the
['message' => $exception->getMessage()], if that is the desired format, in the normalizer instead of the event subscriber.No reason, it needs to take precedence over the parent. Since the parent is at
-75and the grandparent at0I thought that-50could be a sensible number. Do you think it's too early?Comment #20
sutharsan commentedComment #21
wim leersThat makes sense! Can you open a new issue for that? We still have to clean up the current HTTP exception mess for non-HTML formats. So we might as well fix that at the same time.
Thanks for the clarifications!
Comment #22
e0ipsoComment #23
e0ipsoAdded a reference to the core issue.