PageRenderTime 47ms CodeModel.GetById 39ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/scalate-core/src/main/resources/WEB-INF/scalate/errors/500.scaml

http://github.com/scalate/scalate
Unknown | 212 lines | 199 code | 13 blank | 0 comment | 0 complexity | 53f918f5e9728dd2c2b022d6b110610e MD5 | raw file
  1-#
  2-# Copyright (C) 2009-2011 the original author or authors.
  3-# See the notice.md file distributed with this work for additional
  4-# information regarding copyright ownership.
  5-#
  6-# Licensed under the Apache License, Version 2.0 (the "License");
  7-# you may not use this file except in compliance with the License.
  8-# You may obtain a copy of the License at
  9-#
 10-#     http://www.apache.org/licenses/LICENSE-2.0
 11-#
 12-# Unless required by applicable law or agreed to in writing, software
 13-# distributed under the License is distributed on an "AS IS" BASIS,
 14-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15-# See the License for the specific language governing permissions and
 16-# limitations under the License.
 17-#
 18- if ( !engine.isDevelopmentMode )
 19  .scalate-error-500
 20    %h1 Server Error: We're sorry, but something went wrong.
 21    %p We've been notified about this issue and we'll take a look at it shortly.
 22
 23- else
 24  - import scala.util.parsing.input.Position
 25  - import org.fusesource.scalate._
 26  - import org.fusesource.scalate.console._
 27  - val consoleHelper = new ConsoleHelper(context)
 28  - import consoleHelper._
 29  - response.setContentType("text/html")
 30  - attributes("layout") = ""
 31  !!! Basic
 32  %html(lang="en")
 33    %head
 34      %meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
 35      %meta(name="keywords" content="error")
 36      %title Unexpected Failure
 37      %style(type="text/css")
 38        :plain
 39          html, body {
 40              margin: 0;
 41              padding: 0;
 42              font-family: Helvetica, Arial, Sans;
 43              background: #EEEEEE;
 44          }
 45          .block {
 46              padding: 20px;
 47              border-bottom: 1px solid #aaa;
 48          }
 49          #scalate-error .header h1 {
 50              font-weight: normal;
 51              font-size: 28px;
 52              margin: 0;
 53          }
 54          #scalate-error .more {
 55              color: #666;
 56              font-size: 80%;
 57              border: none;
 58          }
 59          #scalate-error .header {
 60              background: #fcd2da;
 61          }
 62          #scalate-error .header p {
 63              color: #333;
 64          }
 65          #scalate-error .details {
 66              background: #f6f6f6;
 67          }
 68          #scalate-error .details h2 {
 69              font-weight: normal;
 70              font-size: 18px;
 71              margin: 0 0 10px 0;
 72          }
 73          #scalate-error .details .lineNumber {
 74              float: left;
 75              display: block;
 76              width: 40px;
 77              text-align: right;
 78              margin-right: 10px;
 79              font-size: 14px;
 80              font-family: monospace;
 81              background: #333;
 82              color: #fff;
 83          }
 84          #scalate-error .details .line {
 85              clear: both;
 86              color: #333;
 87              margin-bottom: 1px;
 88          }
 89          #scalate-error .details pre {
 90              font-size: 14px;
 91              margin: 0;
 92              overflow-x: hidden;
 93          }
 94          #scalate-error .details .error {
 95              color: #c00 !important;
 96          }
 97          #scalate-error .details .error .lineNumber {
 98              background: #c00;
 99          }
100          #scalate-error .details .errorCol {
101              background: #c00;
102              color:#fff;
103          }
104          #scalate-error .details a {
105              text-decoration: none;
106          }
107          #scalate-error .details a:hover * {
108              cursor: pointer !important;
109          }
110          #scalate-error .details a:hover pre {
111              background: #FAFFCF !important;
112          }
113
114          #scalate-error .details .stacktrace {
115              clear: both;
116              color: #333;
117              margin-bottom: 1px;
118              font-size: 10px;
119          }
120
121          #scalate-error .nested {
122            padding-top:10px;
123            padding-left:10px;
124          }
125
126          #scalate-error .nested .block {
127            padding:10px;
128          }
129          #scalate-error .nested .header {
130            font-size:10px;
131          }
132          #scalate-error .nested .header h1 {
133            font-size:16px;
134          }
135    %body
136      #content
137        .wrapper
138          -# Wrap in a try catch block so if there is a error on this page it gets logged to the console
139          - try
140            %link(href={uri("/css/scalate/errors.css")} rel="stylesheet" type="text/css")
141  
142            - def displayError(file:String, pos:Position, message:String)
143              .header.block
144                %h1
145                  = message
146
147              .details.block
148                %h2
149                  = editLink(file, pos.line, pos.column)
150                    in #{shorten(file)} near line #{pos.line} col #{pos.column}
151
152                - for (s <- lines(file, pos))
153                  - val ss = s.style(pos.line)
154                  = editLink(file, s.line, (if (pos.line == s.line) pos.column else 1))
155                    %div(class=ss)
156                      %span.lineNumber
157                        = s.line
158                      - if (pos.line == s.line)
159                        - val (prefix, ch, postfix) = s.splitOnCharacter(pos.column - 1)
160                        %pre<
161                          &~ prefix
162                          %span.errorCol><
163                            &~ ch
164                          &~ postfix
165                      - else
166                        %pre<
167                          &~ s.source
168
169            - def displayException(e:Throwable)
170              .header.block
171                %h1
172                  = e.getMessage
173                %p
174                  = e
175              .details.block
176                - for( stack <- e.getStackTrace )
177                  = renderStackTraceElement(stack)
178                - if( e.getCause!=null )
179                  .nested
180                    - displayException(e.getCause)
181
182            #scalate-error
183              - exception match
184                - case e:InvalidSyntaxException =>
185                  - displayError( e.template, e.pos, e.brief)
186
187                - case e:CompilerException =>
188                  - for ( error <- e.errors )
189                    - displayError(error.file, error.pos, error.message)
190                    - val o = error.original
191                    - if (o != null)
192                      .section.block
193                        = editLink(o.file, o.pos.line, o.pos.column)
194                          from generated #{shorten(o.file)} near line #{o.pos.line} col #{o.pos.line}
195
196                - case e:Throwable =>
197                  - displayException(e)
198
199                - case u =>
200                  .header.block
201                    %h1
202                      = errorMessage
203                    %p
204                      = u
205          - catch
206            - case e:Throwable=>
207            - e.printStackTrace
208            -# Fallback to a simple rendering of the error message
209            .header.block
210              %h1
211                = errorMessage
212