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. 🫢


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