1<%doc>
2
3(Slightly more) user-friendly error messages
4
5</%doc>
6
7
8<%args>
9$error
10$user           => $ui->get_current_user($r)
11$showplainerror => 0
12</%args>
13
14<%init>
15my $caller = $m->caller->name;
16my $err_msg;
17my $trace;
18#
19# Try to customize the error message depending on the nature of the error.
20#
21# Fatal errors could be caused by bugs in the code, or by invalid user input
22# we want to hide the stack trace, but if the user believes it is a bug
23# we want the user to report it to their netdot administrator, who may submit a bug
24# report to us.  This may be either a Netdot Fatal exception or a Mason Exception
25
26if ( ref($error) =~ /Netdot::Util::Exception/ ){
27    if ( $error->isa_netdot_exception('Fatal') ){
28	# Let's separate the error message from the stack trace
29	$trace = $error->trace->as_string;
30    }
31    $err_msg = $error->error;
32}else{
33    $err_msg = $error;
34}
35
36</%init>
37
38% if ( !$showplainerror ) {
39    <div id="sectiondetail">
40        <div class="container">
41            <div class="containerhead">Error</div>
42            <div class="containerbody">
43% }
44
45<p>
46<strong><% $caller %></strong> produced the following error:
47<p>
48<pre>
49
50<% $err_msg %>
51
52</pre>
53
54% if ( $trace ){
55
56      <p>
57      This may be the result of invalid user input. However, if you believe this is a bug, please <a href="#" onClick="toggleLayer('stacktrace');">click here</a>, then copy the full error message and send it to
58      <a href="mailto:<% Netdot->config->get('ADMINEMAIL') %>"><% Netdot->config->get('ADMINEMAIL') %></a>
59      </p>
60
61      <div id="stacktrace" style="display:none"><% $trace %></div>
62
63% }else{
64      <p>
65      Please <a class="hand" onClick="history.go(-1);">go back</a> and try again.
66      </p>
67% }
68
69% if( !$showplainerror ) {
70        </div> <!-- close containerbody -->
71    </div> <!-- close container -->
72</div> <!-- close sectiondetail -->
73% }
74
75<%perl>
76# Abort execution of the caller
77$m->abort;
78</%perl>
79