forked from agordon/dancer_bootstrap_fontawesome_template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package examples::error_handling; | ||
use Dancer ':syntax'; | ||
use strict; | ||
use warnings; | ||
|
||
=pod | ||
This module demonstrates Dancer's error handling capabilities, in development and production modes. | ||
=cut | ||
|
||
get '/error_handling' => sub { | ||
template 'examples/error_handling'; | ||
}; | ||
|
||
post '/error_handling' => sub { | ||
my $show_errors = param 'showerrors'; | ||
print STDERR "show_errors = $show_errors\n"; | ||
$show_errors = 1 unless $show_errors eq "0"; | ||
|
||
=pod | ||
NOTE: | ||
In a real project, you should never set "show_errors" like this. | ||
Set it properly in both "./environments/development.yml" and | ||
./environments/production.yml" . | ||
=cut | ||
set show_errors => $show_errors; | ||
die "Oops, I did it again"; | ||
}; | ||
|
||
true; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
[%### | ||
This page demonstrates Dancer's stack-trace error handling in development mode. | ||
###%] | ||
|
||
<!-- BootStrap NavBar --> | ||
<div class="navbar"> | ||
<div class="navbar-inner"> | ||
<div class="container"> | ||
<h3><a class="brand" href="[% request.uri_base %]"><img src="images/dancer_man.png"> Perl Dancer</a></h3> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- HEADER line --> | ||
<div class="container"> | ||
|
||
<div class="page-header"> | ||
<div class="row"> | ||
<div class="span12"> | ||
<h2>Dancer + Bootstrap Exapmles<//h2> | ||
<h1>Dancer's Error Handling</h1> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="span12"> | ||
|
||
This page demonstrates Dancer's error handling code, in development and production modes. | ||
<br/> | ||
In development mode, any <code>die</code> statement will generate a detailed stack-trace with loads of information. In production mode, <code>die</code> statements will generate a generic error message. | ||
<br/> | ||
<br/> | ||
|
||
<h3>Code Highlights</h3> | ||
<ul> | ||
<li>The Dancer code is in | ||
<a href="[% request.uri_for("/show_file",file => "error_handling.pm", example => "Error Handling", url => request.uri_for("/error_handling") ) %]"> | ||
<code>./lib/examples/error_handling.pm</code> <i class="icon-eye-open"></i> </a>. | ||
</li> | ||
|
||
<li>This HTML tempate is in | ||
<a href="[% request.uri_for("/show_file",file => "error_handling.tt", example => "Error Handling", url => request.uri_for("/error_handling") ) %]"> | ||
<code>./views/examples/error_handling.tt</code> <i class="icon-eye-open"></i> </a>. | ||
</li> | ||
<li>Showing or hiding the detailed error information is controlled by the <a target="_blank" href="http://search.cpan.org/dist/Dancer/lib/Dancer/Introduction.pod#EXECUTION_ERRORS">show_errors</a> configuration key - which can be set either in the YML configuration files or at runtime.</li> | ||
<li>Standard Dancer applications have <a target="_blank" href="http://search.cpan.org/dist/Dancer/lib/Dancer/Introduction.pod#CONFIGURATION_AND_ENVIRONMENTS">two YML configuration files</a>: <strong>development</strong> settings go in <code>./environments/development.yml</code> and <strong>production</strong> settings go in <code>./environment/production.yml</code>.</li> | ||
</ul> | ||
|
||
</div> | ||
</div> | ||
|
||
<br/> | ||
<br/> | ||
|
||
<div class="row"> | ||
<div class="span12"> | ||
[%################################ | ||
Error Handling Example starts here | ||
#################################%] | ||
|
||
<form class="form-horizontal" method="post"> | ||
<fieldset> | ||
<legend>Error Handling Example</legend> | ||
|
||
<div class="alert alert-info"> | ||
By clicking on the button below, you will get a <strong>Runtime error message</strong> - it's not a bug - it's the whole point of this demonstration. | ||
</div> | ||
|
||
<!-- Radio Buttons Controls --> | ||
<div class="control-group"> | ||
<label class="control-label">Show errors</label> | ||
<div class="controls"> | ||
<label class="radio"> | ||
<input type="radio" name="showerrors" id="showerror1" value="1" checked> | ||
yes (development mode) | ||
</label> | ||
<label class="radio"> | ||
<input type="radio" name="showerrors" id="showerror2" value="0"> | ||
no (production mode) | ||
</label> | ||
</div> | ||
</div> | ||
|
||
|
||
<!-- The Submit buttons --> | ||
<div class="form-actions"> | ||
<button type="submit" class="btn btn-primary">Crash and Burn!</button> | ||
</div> | ||
</fieldset> | ||
</form> | ||
|
||
</div> | ||
</div> |
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