-
Notifications
You must be signed in to change notification settings - Fork 9
Exception message not transferred to response #24
Comments
Ah heck. It's even more complicated than this. The message is being placed in the body, but I was not seeing the body at all, because it's an AJAX call. So what I really need is some way to bubble the error up to my code (out of |
Ah so! Is it that HTTP 500 response is not supposed to supply a content-body ? |
I'm trying to decipher that right now, from this W3C document.
The question becomes, what is an "entity" that should be included? Is that a header or body? |
Section 1.3 Terminology:
The answer remains vague. :-p |
My brain is starting to hurt. |
|
My conclusion at the moment is that returning an error message (description) in either a header or body meets the SHOULD of the HTTP spec. My general inclination for most errors would be to set error status and message in a Payload, and let the application's specific Responder deal with appropriately notifying the user. But this is in the middleware. It's harder to think through an appropriate general solution, since we might be in the middle of a chain of several middlewares. Hmm. |
That's my inclination as well. |
I think in my problem situation, the Domain class which was supposed to create the Payload is the missing class, so it's fallen back on the infrastructure (Relay, Radar) to deal with the problem. There's not really the usual Payload with its convenient attributes, I don't think. But somehow I need to inform the Responder so that it can do something more intelligent, even though that rather feels like the wrong place for the logic. Hmm. |
In
\Relay\Middleware\ExceptionHandler\__invoke()
, it attempts to place the exception message in theResponse
, but yet by the timeRadar
gets theResponse
back to call theResponder
, the message has been overwritten. This results in a frustrating to debugHTTP 500
error with no further information.Here's the stack at the
try {
in the above method:Here's the relevant data at that same point:
Note that the correct exception message regarding the missing class is present at this point inside the exception object.
But then this line in the
catch
is called:Here's that method from
\Zend\Diactoros\Response
:Note that it overwrites the
reasonPhrase
with an empty string if no second argument is passed to the method call.I think that
Relay\Middleware\ExceptionHandler\__invoke()
should probably be passing$e->message
like this towithStatus(500, $e->getMessage())
.The text was updated successfully, but these errors were encountered: