/scalate-core/src/main/resources/WEB-INF/scalate/errors/500.scaml
Unknown | 212 lines | 199 code | 13 blank | 0 comment | 0 complexity | 53f918f5e9728dd2c2b022d6b110610e MD5 | raw file
- -#
- -# Copyright (C) 2009-2011 the original author or authors.
- -# See the notice.md file distributed with this work for additional
- -# information regarding copyright ownership.
- -#
- -# Licensed under the Apache License, Version 2.0 (the "License");
- -# you may not use this file except in compliance with the License.
- -# You may obtain a copy of the License at
- -#
- -# http://www.apache.org/licenses/LICENSE-2.0
- -#
- -# Unless required by applicable law or agreed to in writing, software
- -# distributed under the License is distributed on an "AS IS" BASIS,
- -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -# See the License for the specific language governing permissions and
- -# limitations under the License.
- -#
- - if ( !engine.isDevelopmentMode )
- .scalate-error-500
- %h1 Server Error: We're sorry, but something went wrong.
- %p We've been notified about this issue and we'll take a look at it shortly.
- - else
- - import scala.util.parsing.input.Position
- - import org.fusesource.scalate._
- - import org.fusesource.scalate.console._
- - val consoleHelper = new ConsoleHelper(context)
- - import consoleHelper._
- - response.setContentType("text/html")
- - attributes("layout") = ""
- !!! Basic
- %html(lang="en")
- %head
- %meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
- %meta(name="keywords" content="error")
- %title Unexpected Failure
- %style(type="text/css")
- :plain
- html, body {
- margin: 0;
- padding: 0;
- font-family: Helvetica, Arial, Sans;
- background: #EEEEEE;
- }
- .block {
- padding: 20px;
- border-bottom: 1px solid #aaa;
- }
- #scalate-error .header h1 {
- font-weight: normal;
- font-size: 28px;
- margin: 0;
- }
- #scalate-error .more {
- color: #666;
- font-size: 80%;
- border: none;
- }
- #scalate-error .header {
- background: #fcd2da;
- }
- #scalate-error .header p {
- color: #333;
- }
- #scalate-error .details {
- background: #f6f6f6;
- }
- #scalate-error .details h2 {
- font-weight: normal;
- font-size: 18px;
- margin: 0 0 10px 0;
- }
- #scalate-error .details .lineNumber {
- float: left;
- display: block;
- width: 40px;
- text-align: right;
- margin-right: 10px;
- font-size: 14px;
- font-family: monospace;
- background: #333;
- color: #fff;
- }
- #scalate-error .details .line {
- clear: both;
- color: #333;
- margin-bottom: 1px;
- }
- #scalate-error .details pre {
- font-size: 14px;
- margin: 0;
- overflow-x: hidden;
- }
- #scalate-error .details .error {
- color: #c00 !important;
- }
- #scalate-error .details .error .lineNumber {
- background: #c00;
- }
- #scalate-error .details .errorCol {
- background: #c00;
- color:#fff;
- }
- #scalate-error .details a {
- text-decoration: none;
- }
- #scalate-error .details a:hover * {
- cursor: pointer !important;
- }
- #scalate-error .details a:hover pre {
- background: #FAFFCF !important;
- }
- #scalate-error .details .stacktrace {
- clear: both;
- color: #333;
- margin-bottom: 1px;
- font-size: 10px;
- }
- #scalate-error .nested {
- padding-top:10px;
- padding-left:10px;
- }
- #scalate-error .nested .block {
- padding:10px;
- }
- #scalate-error .nested .header {
- font-size:10px;
- }
- #scalate-error .nested .header h1 {
- font-size:16px;
- }
- %body
- #content
- .wrapper
- -# Wrap in a try catch block so if there is a error on this page it gets logged to the console
- - try
- %link(href={uri("/css/scalate/errors.css")} rel="stylesheet" type="text/css")
-
- - def displayError(file:String, pos:Position, message:String)
- .header.block
- %h1
- = message
- .details.block
- %h2
- = editLink(file, pos.line, pos.column)
- in #{shorten(file)} near line #{pos.line} col #{pos.column}
- - for (s <- lines(file, pos))
- - val ss = s.style(pos.line)
- = editLink(file, s.line, (if (pos.line == s.line) pos.column else 1))
- %div(class=ss)
- %span.lineNumber
- = s.line
- - if (pos.line == s.line)
- - val (prefix, ch, postfix) = s.splitOnCharacter(pos.column - 1)
- %pre<
- &~ prefix
- %span.errorCol><
- &~ ch
- &~ postfix
- - else
- %pre<
- &~ s.source
- - def displayException(e:Throwable)
- .header.block
- %h1
- = e.getMessage
- %p
- = e
- .details.block
- - for( stack <- e.getStackTrace )
- = renderStackTraceElement(stack)
- - if( e.getCause!=null )
- .nested
- - displayException(e.getCause)
- #scalate-error
- - exception match
- - case e:InvalidSyntaxException =>
- - displayError( e.template, e.pos, e.brief)
- - case e:CompilerException =>
- - for ( error <- e.errors )
- - displayError(error.file, error.pos, error.message)
- - val o = error.original
- - if (o != null)
- .section.block
- = editLink(o.file, o.pos.line, o.pos.column)
- from generated #{shorten(o.file)} near line #{o.pos.line} col #{o.pos.line}
- - case e:Throwable =>
- - displayException(e)
- - case u =>
- .header.block
- %h1
- = errorMessage
- %p
- = u
- - catch
- - case e:Throwable=>
- - e.printStackTrace
- -# Fallback to a simple rendering of the error message
- .header.block
- %h1
- = errorMessage