Created
September 13, 2011 14:18
-
-
Save LoonyPandora/1213906 to your computer and use it in GitHub Desktop.
Dancer error catching.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kapowaz; | |
use Dancer ':syntax'; | |
use Dancer::Serializer::Mutable; | |
our $VERSION = '0.1'; | |
get '/' => sub { | |
template 'index'; | |
}; | |
# With error_template specified, show_errors off, and don't try to serialize | |
# shows me error.tt | |
prefix '/error_template'; | |
get '/die' => sub { | |
set serializer => undef; | |
set show_errors => 0; | |
set error_template => "error.tt"; | |
die "Fission Mailed"; | |
}; | |
# With show_errors turned on, and don't try to serialize | |
# shows me dancer stack trace | |
prefix '/show_errors'; | |
get '/die' => sub { | |
set serializer => undef; | |
set show_errors => 1; | |
die "Fission Mailed"; | |
}; | |
# Show errors off, and default template used. | |
# Shows public/500.html | |
prefix undef; | |
get '/die' => sub { | |
set serializer => undef; | |
set show_errors => 0; | |
die "Fission Mailed"; | |
}; | |
# Returning JSON | |
# Returns JSON representation of the error - and ignores error.tt | |
prefix '/json'; | |
get '/die' => sub { | |
set serializer => 'JSON'; | |
set error_template => "error.tt"; | |
set show_errors => 1; | |
die "Fission Mailed"; | |
}; | |
# Returning Mutable | |
# Returns mutable representation of the error - and ignores error.tt | |
prefix '/mutable'; | |
get '/die' => sub { | |
set serializer => 'mutable'; | |
set error_template => "error.tt"; | |
set show_errors => 1; | |
die "Fission Mailed"; | |
}; | |
true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment