Dancer::Error(3pm)
π Dancer::Error β the class for representing fatal errors π
okay bestie, so this is Dancer::Error, part of the User Contributed Perl Documentation squad, and it's the page for version 1.3522. yes, that's the version, we're stating it up front like the queen it is. π
β¨ NAME β¨
Dancer::Error β the class that represents fatal errors. it's giving "something went wrong but we're gonna show it cute instead of just dying." π
πΈ VERSION πΈ
version 1.3522 π
π SYNOPSIS π
here's the vibe, bestie β straight from send_file:
# taken from send_file:
use Dancer::Error;
my $error = Dancer::Error->new(
code => 404,
message => "No such file: `$path'"
);
$error->render;
see how easy that was?? immaculate. β¨
π¦ DESCRIPTION π¦
so with Dancer::Error you can throw reasonable-looking errors at your user instead of crashing the whole app and filling up the logs with chaos. no cap.
this is usually used in debugging environments, and fr it's what Dancer itself uses under debugging to catch errors and show them on screen. main character energy tbh. π
π ATTRIBUTES π
code
the code that caused the error. like 404, 500, you know the drill.
heads up bestie: this is only an attribute getter, so you'll have to set it at new. no changing it later, periodt.
title
the title of the error page. π
reminder: getter only. set it at new. π
message
the message of the error page.
yep, getter only. set it at new. π«Ά
exception
the exception that caused the error. if the error was not caused by an exception, it returns undef. exceptions are usually objects that inherit from Dancer::Exception.
getter only, babe. set it at new. π
π₯ METHODS/SUBROUTINES π₯
new
create a new Dancer::Error object. iconic. here's what you can pass:
titleβ the title of the error page.typeβ what type of error this is.codeβ the code that caused the error.messageβ the message that will appear to the user.exceptionβ the exception that will be useable by the rendering.
backtrace
create a backtrace of the code where the error is caused. π΅οΈββοΈ
this method tries to find out where the error appeared according to the actual error message (using the message attribute) 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. detective work, honestly. π
tabulate
small subroutine to help output nicer. it's the little helper that could. π₯Ί
dumper
this uses Data::Dumper to create nice content output with a few predefined options. β¨
render
renders a response using Dancer::Response. this is the moment where it all comes together, bestie. π¬
environment
a main function to render environment information: the caller (using get_caller), the settings and environment (using dumper) and more. the full tour. π
get_caller
creates a stack trace of callers. who called whom, we're keeping receipts. π
_censor
an internal method that tries to censor out content which should be protected. π«£
dumper calls this method to censor things like passwords and such. protect the girlies' secrets!! π
_html_encode
internal method to encode entities that are illegal in (X)HTML. we output as UTF-8, so there's no need to encode all non-ASCII characters or use a module.
FIXME : this is not true any more, output can be any charset. Need fixing. π (not me pointing out the bug note, but it's literally in the source)
π AUTHOR π
Dancer Core Developers. legends only. π«Ά
πΈ COPYRIGHT AND LICENSE πΈ
this software is copyright (c) 2010 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. slay. π
and that's the whole page, bestie!! β¨ this was Dancer::Error from perl v5.40.1, dated 2026-05-05 β gen perl v5.40.1, date 2026-05-05, page Dancer::Error(3pm). now go forth and throw beautiful errors. π
ππ
π¦ where this page comes from
- ubuntu stonking: libdancer-perl 1.3522-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms