Dancer2...::Error(3)
π Dancer2::Core::Error π
okay bestie, so this is the manual page for Dancer2::Core::Error, straight out of the User Contributed Perl Documentation, section 3. grab a snack, we're talking about fatal errors and honestly it's giving main character energy β¨
π NAME π
Dancer2::Core::Error β the class that represents fatal errors. that's it, that's the whole vibe. π
β VERSION β
version 2.2.1 β she's versioned, she's valid, she's on the clock. π
π¦ SYNOPSIS π¦
here's how you actually use her, no cap:
use Dancer2::Core::Error;
my $error = Dancer2::Core::Error->new(
status => 404,
message => "No such file: `$path'"
);
$error->throw;
πΈ DESCRIPTION πΈ
so with Dancer2::Core::Error you can throw reasonable-looking errors to the user instead of just crashing the whole application and flooding your logs like π. the logs deserve peace too.
this is usually the move in debugging environments, and it's literally what Dancer2 itself uses under debugging β to catch errors and show them right there on screen. iykyk. π₯
π ATTRIBUTES π
show_stacktrace
(the original page doesn't say anything beyond the name here, bestie β not me inventing lore, i would never) π
charset
(same deal β name only on the original page, so that's all i'm giving you)
type
the error type. simple as that. β¨
title
the title of the error page.
β οΈ this one is only an attribute getter β you have to set it at new. you can't just go changing it later, she's set in her ways. π
status
the status that caused the error.
β οΈ also only an attribute getter β set it at new or it's not happening.
message
the message of the error page. the whole point tbh. π
censor
the function used to censor error messages. by default it uses the censor method of Data::Censor.
# default censor function used by `error_censor`
# is equivalent to
sub MyApp::censor {
Data::Censor->new(
sensitive_fields => qr/pass|card.?num|pan|secret/i,
replacement => "Hidden (looks potentially sensitive)",
)->censor(@_);
}
setting error_censor => 'MyApp::censor';
you can configure it through the app setting error_censor. if you provide it, error_censor has to be the fully qualified name of the censor function. that function is expected to take in the data as a hashref, modify it in place, and return the number of items 'censored'. yes, in place, she's hands-on like that. π«Ά
for example, using Data::Censor:
# in config.yml
error_censor: MyApp::Censor::censor
# in MyApp::Censor
package MyApp::Censor;
use Data::Censor;
my $data_censor = Data::Censor->new(
sensitive_fields => [ qw(card_number password hush) ],
replacement => '(Sensitive data hidden)',
);
sub censor { $data_censor->censor(@_) }
1;
and as a lil shortcut, error_censor can also be the key/value combo of a class and the arguments for its constructor. the created object is expected to have a censor method. so the Data::Censor use above could also have been done via the config:
error_censor:
Data::Censor:
sensitive_fields:
- card_number
- password
- hush
replacement: '(Sensitive data hidden)'
look at that glow up. two ways, same slay. π
π METHODS π
my $error = new Dancer2::Core::Error(status => 404, message => "No such file: $path'");`
creates a new Dancer2::Core::Error object. for the available arguments, go peek at ATTRIBUTES above, bestie. π
supported_hooks ();
yep, that's the signature. that's what it says. π
throw($response)
populates the content of the response with the error's information. if $response isn't given, it acts on the app attribute's response instead. so like, she'll find a response herself if you don't hand her one. independent queen. π
backtrace
shows the surrounding lines of context at the line where the error was thrown.
this method tries to figure out where the error appeared based on the actual error message (it uses the message attribute for that) and tries to parse it β supporting the regular/default Perl warning or error pattern and the Devel::SimpleTrace output β and then returns an error-highlighted message. she's doing detective work fr fr. π
environment
the main function for rendering environment info: the caller (via get_caller), the settings and environment (via dumper), and more. the full ~aesthetic~ of your situation. β¨
get_caller
creates a stack trace of callers. so you can see who called what. it's giving receipts. π§Ύ
π FUNCTIONS π
_censor
a private function that tries to censor out content which should be protected.
dumper calls this method to censor things like passwords and such. protecting the sensitive stuff, as she should. π
my $string = _html_encode ($string);
private function that replaces illegal entities in (X)HTML with their escaped representations.
π html_encode() doesn't do any UTF black magic. none. zero. don't come for her about it. π
dumper
this uses Data::Dumper to create nice content output with a few predefined options. pretty output, minimal effort. ate. π
π AUTHOR π
Dancer Core Developers β the collective, the squad, the legends. π
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2026 by Alexis Sukrieh.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free is free, bestie, go wild. π¦
aaaand that's the whole page, bestie!! π this was generated for perl v5.42.3 and dated 2026-09-20, and the manual you just read is Dancer2::Core::Error(3) from the User Contributed Perl Documentation. go throw some beautiful errors, you're gonna do amazing πβ¨πΈ
π¦ where this page comes from
- fedora 44: perl-Dancer2 2.2.1-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms