StackTrace middleware options

Showing 1-6 of 6 messages
StackTrace middleware options Stefan Geneshky 6/25/13 10:25 PM
Plack::Runner adds Lint and StackTrace to each application running in development mode. This comes very handy for framework developers.
There is, however, one tiny inconvenience. There is no way to add parameters to those middleware.  
So, if one wants to add { force => 1 } to StackTrace, there is no other way, but to wrap it again with those params.
Would it make sense to add %ENV variables with options, which Plack::Runner::prepare_devel would look for when loading the development middleware?
I elect myself to write the code, so if it's a matter of "it's not a bad idea, but I don't feel like doing it" then no worries.

Cheers,
Stefan
Re: StackTrace middleware options Tatsuhiko Miyagawa 6/26/13 6:19 PM
On Tue, Jun 25, 2013 at 10:25 PM, Stefan Geneshky <stefa...@gmail.com> wrote:
> Plack::Runner adds Lint and StackTrace to each application running in
> development mode. This comes very handy for framework developers.
> There is, however, one tiny inconvenience. There is no way to add parameters
> to those middleware.

I think if user has to set %ENV for middleware options, it'd be much
easier to run the app with non-development environment (Or with
--no-default-middleware) and enable middleware with options
themselves.



--
Tatsuhiko Miyagawa
Re: StackTrace middleware options Stefan Geneshky 6/26/13 6:25 PM
The %ENV variable is not for the users. It's for the framework developers. 

The Plack::Middleware::StackTrace POD for "force" says:
The use case of this option is that when your framework catches all the exceptions in the main handler and returns all failures in your code as a normal 500 PSGI error response. In such cases, this middleware would never have a chance to display errors because it can't tell if it's an application error or just random eval in your code. This option enforces the middleware to display stack trace even if it's not the direct error thrown by the application.

There is, however, no way for the framework to raise the "force" flag, hence an %ENV (or another solution) is needed.

Stefan Geneshky



--

---
You received this message because you are subscribed to a topic in the Google Groups "psgi-plack" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psgi-plack/SG2YBfg8OxU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psgi-plack+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Re: StackTrace middleware options Tatsuhiko Miyagawa 6/26/13 6:57 PM
I see what you mean, but no, in PSGI there's no way for the *apps* to
affect how the runtime behaves. It's a separation of interests and app
can't and shouldn't control how it's run.

I understand that the wording of the POD might be confusing such that
a framework can request how middleware behaves. I think it should
better be fixed.
> You received this message because you are subscribed to the Google Groups
> "psgi-plack" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to psgi-plack+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Tatsuhiko Miyagawa
Re: StackTrace middleware options Tatsuhiko Miyagawa 6/26/13 7:02 PM
> Plack::Runner adds Lint and StackTrace to each application running in development mode. This comes very handy for framework developers.

I guess there's a disconnect here. StackTrace (and Lint) is added for
the convenience of users, not framework developers. It's up to user's
choice whether to apply this middleware by default (with
--no-default-middleware flags).

Speaking of the actual problem, "force" option - this is only required
when a framework catches exception by themselves and don't propagate
to outside the app. Instead of requesting the "force" option, I
suppose a) your framework throws exceptions when stacktrace is
enabled, or b) set some PSGI $env (not %ENV) variable that is
equivalent to the "force" option in StackTrace, so that the middleware
can handle it as an error.

I'm happy to accept pull request for StackTrace middleware, along these lines.


--
Tatsuhiko Miyagawa
Re: StackTrace middleware options Stefan Geneshky 6/26/13 7:15 PM

Setting a PSGI env sounds like a good solution. I'll send you a pull request in the next few days.

Cheers.

--

---
You received this message because you are subscribed to a topic in the Google Groups "psgi-plack" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psgi-plack/SG2YBfg8OxU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psgi-plack+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.