Hi Josh,

I've been having a good old think about what you asked, as it confused me a 
little being that I don't code that way myself.

To me, exception handling, to be effective, should happen at your 
application level, not at such a low level as middleware; in my 
applications, the function calling $stack->exchange(...); would be wrapped 
in an application wide exception handler which would return a response 
based on that.

I'm concerned here for splitting out responsibilities in code, so that the 
middleware are responsible for creating a response, and if they can't, 
throw an exception. The stack is not the top level of an application, it is 
to be used inside an application; the app itself should be responsible for 
final output whether that be a true response or a handled exception.

If we had a router at the centre of the stack that talked to a domain, then 
of course that could catch any domain exceptions and translate them into a 
response or even throw an application level exception.

On Wednesday, 22 February 2017 11:17:37 UTC, John Porter wrote:
>
> Please point me to examples that I can replicate, otherwise I can't answer 
> your questions accurately.
>
> Thanks
>
> On Wednesday, 22 February 2017 11:13:26 UTC, Josh Di Fabio wrote:
>>
>> Hi John,
>>
>> How would you implement a middleware which catches an exception thrown by 
>> an inner middleware and returns a response instead of allowing the 
>> exception to bubble up?
>>
>> On Wed, Feb 22, 2017 at 11:06 AM Michael Mayer <mic...@schnittstabil.de> 
>> wrote:
>>
>>> John, would you mind pushing your interfaces and Stack to github? Thus, 
>>> everybody interested can play with your code, which probably would reduce 
>>> mails here.
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "PHP Framework Interoperability Group" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to php-fig+u...@googlegroups.com.
>>> To post to this group, send email to php...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/php-fig/a2156982-48f3-424f-b14a-4cb81a6e5335%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/php-fig/a2156982-48f3-424f-b14a-4cb81a6e5335%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to php-fig+unsubscr...@googlegroups.com.
To post to this group, send email to php-fig@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/7944b8ce-4cff-4fbf-a6bf-76c0dd4fe872%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to