table of contents
Plack::Middleware::StackTrace(3) | User Contributed Perl Documentation | Plack::Middleware::StackTrace(3) |
NAME¶
Plack::Middleware::StackTrace - Displays stack trace when your app dies
SYNOPSIS¶
enable "StackTrace";
DESCRIPTION¶
This middleware uses $SIG{__DIE__} to intercept all exceptions (run-time errors) happening in your application, even those that are caught. For each exception it builds a detailed stack trace.
If the applications aborts by throwing an exception it will be caught and matched against the saved stack traces. If a match is found it will be displayed as a nice stack trace screen, if not then the exception will be reported without a stack trace.
The stack trace is also stored in the environment as a plaintext and HTML under the key "plack.stacktrace.text" and "plack.stacktrace.html" respectively, so that middleware further up the stack can reference it.
This middleware is enabled by default when you run plackup in the default development mode.
You're recommended to use this middleware during the development and use Plack::Middleware::HTTPExceptions in the deployment mode as a replacement, so that all the exceptions thrown from your application still get caught and rendered as a 500 error response, rather than crashing the web server.
Catching errors in streaming response is not supported.
Stack Trace Module¶
The Devel::StackTrace::WithLexicals module will be used to capture the stack trace if the installed version is 0.08 or later. Otherwise Devel::StackTrace is used.
Performance¶
Gathering the information for a stack trace via Devel::StackTrace is slow, and Devel::StackTrace::WithLexicals is significantly slower still. This is not usually a concern in development and when exceptions are rare. However, your application may include code that's throwing and catching exceptions that you're not aware of. Such code will run significantly slower with this module.
CONFIGURATION¶
- force
-
enable "StackTrace", force => 1;
Force display the stack trace when an error occurs within your application and the response code from your application is 500. Defaults to off.
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.
- no_print_errors
-
enable "StackTrace", no_print_errors => 1;
Skips printing the text stacktrace to console ("psgi.errors"). Defaults to 0, which means the text version of the stack trace error is printed to the errors handle, which usually is a standard error.
AUTHOR¶
Tokuhiro Matsuno
Tatsuhiko Miyagawa
SEE ALSO¶
Devel::StackTrace::AsHTML Plack::Middleware Plack::Middleware::HTTPExceptions
2024-01-06 | perl v5.40.0 |