Edgewall Software

Ticket #2375: error.cs

File error.cs, 3.4 KB (added by james@…, 6 years ago)

A hacked error.cs file that kind of implements the required functionality. It's nowhere near perfect, but it's mildly functional.

Line 
1<?cs include "header.cs"?>
2
3<div id="ctxtnav" class="nav"></div>
4
5<div id="content" class="error">
6 <?cs if error.type == "TracError" ?>
7  <h3><?cs var:error.title ?></h3>
8  <p class="message">
9  <?cs var:error.message ?>
10  </p>
11
12 <?cs elif error.type == "internal" ?>
13  <h3>Oops...</h3>
14  <div class="message">
15   <strong>Trac detected an internal error:</strong>
16   <pre><?cs var:error.message ?></pre>
17  </div>
18  <p>
19   If you think this really should work and you can reproduce it. Then you
20   should consider to report this problem to the Trac team.
21  </p>
22  <p>
23   Go to <a href="<?cs var:trac.href.homepage ?>"><?cs
24     var:trac.href.homepage ?></a>  and create a new ticket where you describe
25   the problem, how to reproduce it. Don't forget to include the python
26   traceback found below.
27  </p>
28
29 <?cs elif error.type == "permission" ?>
30  <h3>Permission Denied</h3>
31
32    <?cs if trac.authname == "anonymous"?>
33      <p>You are not logged in; if you <a href="<?cs var:trac.href.login?>">login</a>, you may be able to access this page.</
34p>
35      <?cs set:user_has_options = true ?>
36    <?cs /if ?>
37    <?cs if subcount(trac.acl) > 0 ?>
38    <p>
39     You do not have permission to view this page. You could try one of the following instead:
40     <?cs set:user_has_options = true ?>
41    </p>
42    <ul>
43    <?cs each:item = trac.acl?>
44      <?cs if name(item) == "WIKI_VIEW" ?>
45        <?cs set:allowed.ref = trac.href.wiki?>
46        <?cs set:allowed.name = "Wiki" ?>
47      <?cs elif name(item) == "TIMELINE_VIEW" ?>
48        <?cs set:allowed.ref = trac.href.timeline ?>
49        <?cs set:allowed.name = "Timeline" ?>
50      <?cs elif name(item) == "TICKET_VIEW" ?>
51        <?cs set:allowed.ref = trac.href.query?>
52        <?cs set:allowed.name = "Query Tickets" ?>
53      <?cs elif name(item) == "TICKET_CREATE" ?>
54        <?cs set:allowed.ref = trac.href.newticket?>
55        <?cs set:allowed.name = "Create a new ticket" ?>
56      <?cs elif name(item) == "REPORT_VIEW" ?>
57        <?cs set:allowed.ref = trac.href.report?>
58        <?cs set:allowed.name = "Reports" ?>
59      <?cs elif name(item) == "BROWSER_VIEW" ?>
60        <?cs set:allowed.ref = trac.href.browser?>
61        <?cs set:allowed.name = "Source Browser" ?>
62      <?cs elif name(item) == "ROADMAP_VIEW" || name(item) == "MILESTONE_ADMIN" ?>
63        <?cs set:allowed.ref = trac.href.roadmap?>
64        <?cs set:allowed.name = "Roadmap" ?>
65      <?cs elif name(item) == "SEARCH_VIEW" ?>
66        <?cs set:allowed.ref = trac.href.search ?>
67        <?cs set:allowed.name = "Search" ?>
68      <?cs else ?>
69        <?cs set:allowed.ref = false ?>
70        <?cs set:allowed.name = "" ?>
71      <?cs /if ?>
72      <?cs if allowed.name ?>
73        <li><a href="<?cs var:allowed.ref ?>"><?cs var:allowed.name?></a></li>
74      <?cs /if ?>
75
76    <?cs /each ?>
77    </ul>
78    <?cs set:user_has_options = true ?>
79  <?cs /if ?>
80
81  <?cs if user_has_options != true ?>
82    <p class="message">
83    <?cs var:error.message ?>
84    </p>
85  <?cs /if ?>
86  <div id="help">
87   <strong>Note</strong>: See
88   <a href="<?cs var:trac.href.wiki ?>/TracPermissions">TracPermissions</a> for
89   help on managing Trac permissions.
90  </div>
91
92 <?cs /if ?>
93
94 <p>
95  <a href="<?cs var:trac.href.wiki ?>/TracGuide">TracGuide</a>
96  &mdash; The Trac User and Administration Guide
97 </p>
98
99 <?cs if $error.traceback ?>
100  <h4>Python traceback</h4>
101  <pre><?cs var:error.traceback ?></pre>
102 <?cs /if ?>
103
104</div>
105<?cs include "footer.cs"?>