Dancer...n::Base(3pm)

okay so bestie, you're reading the manual for Dancer::Exception::Base from the Dancer...n::Base(3pm) page. let's get into it πŸ’…βœ¨


πŸ’– NAME πŸ’–

Dancer::Exception::Base β€” the base class of all Dancer exceptions. periodt.

✨ VERSION ✨

version 1.3522 β€” lowkey iconic, highkey current.

πŸ¦‹ DESCRIPTION πŸ¦‹

Dancer::Exception::Base is the base class of every Dancer exception. All core exceptions, and all custom exceptions you register using Dancer::Exception::register_exception, inherit from Dancer::Exception::Base. it's giving family tree πŸ‘‘

πŸŽ€ METHODS πŸŽ€

🌸 throw 🌸

Throws an exception. It's what raise (from Dancer::Exception) uses. Any arguments become the raising parameters. You should not use this method directly β€” instead, use raise from Dancer::Exception. bestie, respect the pipeline.

warning: if you want to rethrow an exception, use rethrow. do not just throw it again like a chaotic mess 😭

πŸ’œ rethrow πŸ’œ

Re-throw the exception, without touching its parameters. Useful if you've caught an exception but don't want to handle it, and want to rethrow it. main character energy.

try { ... }
catch {
  my ($e) = @_;
  $e->does('InvalidLogin')
    or $e->rethrow;
  ...
};

🌈 does 🌈

Given an exception type, returns true if the exception is of the same type. slay.

try { raise InvalidLogin => 'foo'; }
catch {
  my ($e) = @_;
  $e->does('InvalidLogin') # true
  ...
};

It can receive more than one type, useful for composed exception, or checking multiple types at once. does performs a logical OR between them:

try { raise InvalidPassword => 'foo'; }
catch {
  my ($e) = @_;
  $e->does('InvalidLogin', 'InvalidPassword') # true
  ...
};

🧚 get_composition 🧚

Returns the composed types of an exception. As every exception inherits of Dancer::Exception::Base, the returned list contains at least 'Base', and the exception class name. it's giving ancestry.com but for exceptions.

warning: the result is a list, so you should call this method in list context. don't be out here scalar-ing it, bestie.
try { raise InvalidPassword => 'foo'; }
catch {
  my ($e) = @_;
  my @list = $e->get_composition()
  # @list contains ( 'InvalidPassword', 'Base', ... )
};

πŸ’– message πŸ’–

Computes and returns the message associated to the exception. It'll apply the parameters that were set at throw time to the message pattern of the exception. cute, useful, we love.

🌟 STRINGIFICATION 🌟

πŸŽ€ string overloading πŸŽ€

All Dancer exceptions properly stringify. When evaluated to a string, they return their message, concatenated with their stack trace (see below). no cap.

πŸ’… cmp overloading πŸ’…

The cmp operator is also overloaded, thus all the string operations can be done on Dancer's exceptions, as they will all be based on the overloaded cmp operator. Dancer exceptions will be compared without their stacktraces. so they're not bringing their baggage into the comparison. we stan.

πŸ”₯ STACKTRACE πŸ”₯

Similarly to Carp, Dancer exceptions stringification appends a string stacktrace to the exception message. the receipts are there.

The stacktrace can be a short one, or a long one. Actually the implementation internally uses Carp.

To enable long stack trace (for debugging purpose), you can use the global variable Dancer::Exception::Verbose (see below).

The short and long stacktrace snippets are stored within "$self-"{_shortmess}> and "$self-"{_longmess}>. Don't touch them or rely on them, they are internals, and will change soon. do not poke the internals, bestie.

πŸ‘‘ GLOBAL VARIABLE πŸ‘‘

πŸ’œ $Dancer::Exception::Verbose πŸ’œ

When set to 1, exceptions will stringify with a long stack trace. This variable is similar to $Carp::Verbose. I recommend you use it like that:

local $Dancer::Exception::Verbose;
$Dancer::Exception::Verbose = 1;

All the Carp global variables can also be used to alter the stacktrace generation. the more you know 🌈

🌸 AUTHOR 🌸

Dancer Core Developers β€” the whole squad.

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.


okay bestie that's the whole page! this was Dancer...n::Base(3pm) β€” generated with perl v5.40.1 on 2026-05-05. slay, you read the whole thing πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from