PageRenderTime 28ms CodeModel.GetById 14ms RepoModel.GetById 0ms 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. - else
  23. - import scala.util.parsing.input.Position
  24. - import org.fusesource.scalate._
  25. - import org.fusesource.scalate.console._
  26. - val consoleHelper = new ConsoleHelper(context)
  27. - import consoleHelper._
  28. - response.setContentType("text/html")
  29. - attributes("layout") = ""
  30. !!! Basic
  31. %html(lang="en")
  32. %head
  33. %meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
  34. %meta(name="keywords" content="error")
  35. %title Unexpected Failure
  36. %style(type="text/css")
  37. :plain
  38. html, body {
  39. margin: 0;
  40. padding: 0;
  41. font-family: Helvetica, Arial, Sans;
  42. background: #EEEEEE;
  43. }
  44. .block {
  45. padding: 20px;
  46. border-bottom: 1px solid #aaa;
  47. }
  48. #scalate-error .header h1 {
  49. font-weight: normal;
  50. font-size: 28px;
  51. margin: 0;
  52. }
  53. #scalate-error .more {
  54. color: #666;
  55. font-size: 80%;
  56. border: none;
  57. }
  58. #scalate-error .header {
  59. background: #fcd2da;
  60. }
  61. #scalate-error .header p {
  62. color: #333;
  63. }
  64. #scalate-error .details {
  65. background: #f6f6f6;
  66. }
  67. #scalate-error .details h2 {
  68. font-weight: normal;
  69. font-size: 18px;
  70. margin: 0 0 10px 0;
  71. }
  72. #scalate-error .details .lineNumber {
  73. float: left;
  74. display: block;
  75. width: 40px;
  76. text-align: right;
  77. margin-right: 10px;
  78. font-size: 14px;
  79. font-family: monospace;
  80. background: #333;
  81. color: #fff;
  82. }
  83. #scalate-error .details .line {
  84. clear: both;
  85. color: #333;
  86. margin-bottom: 1px;
  87. }
  88. #scalate-error .details pre {
  89. font-size: 14px;
  90. margin: 0;
  91. overflow-x: hidden;
  92. }
  93. #scalate-error .details .error {
  94. color: #c00 !important;
  95. }
  96. #scalate-error .details .error .lineNumber {
  97. background: #c00;
  98. }
  99. #scalate-error .details .errorCol {
  100. background: #c00;
  101. color:#fff;
  102. }
  103. #scalate-error .details a {
  104. text-decoration: none;
  105. }
  106. #scalate-error .details a:hover * {
  107. cursor: pointer !important;
  108. }
  109. #scalate-error .details a:hover pre {
  110. background: #FAFFCF !important;
  111. }
  112. #scalate-error .details .stacktrace {
  113. clear: both;
  114. color: #333;
  115. margin-bottom: 1px;
  116. font-size: 10px;
  117. }
  118. #scalate-error .nested {
  119. padding-top:10px;
  120. padding-left:10px;
  121. }
  122. #scalate-error .nested .block {
  123. padding:10px;
  124. }
  125. #scalate-error .nested .header {
  126. font-size:10px;
  127. }
  128. #scalate-error .nested .header h1 {
  129. font-size:16px;
  130. }
  131. %body
  132. #content
  133. .wrapper
  134. -# Wrap in a try catch block so if there is a error on this page it gets logged to the console
  135. - try
  136. %link(href={uri("/css/scalate/errors.css")} rel="stylesheet" type="text/css")
  137. - def displayError(file:String, pos:Position, message:String)
  138. .header.block
  139. %h1
  140. = message
  141. .details.block
  142. %h2
  143. = editLink(file, pos.line, pos.column)
  144. in #{shorten(file)} near line #{pos.line} col #{pos.column}
  145. - for (s <- lines(file, pos))
  146. - val ss = s.style(pos.line)
  147. = editLink(file, s.line, (if (pos.line == s.line) pos.column else 1))
  148. %div(class=ss)
  149. %span.lineNumber
  150. = s.line
  151. - if (pos.line == s.line)
  152. - val (prefix, ch, postfix) = s.splitOnCharacter(pos.column - 1)
  153. %pre<
  154. &~ prefix
  155. %span.errorCol><
  156. &~ ch
  157. &~ postfix
  158. - else
  159. %pre<
  160. &~ s.source
  161. - def displayException(e:Throwable)
  162. .header.block
  163. %h1
  164. = e.getMessage
  165. %p
  166. = e
  167. .details.block
  168. - for( stack <- e.getStackTrace )
  169. = renderStackTraceElement(stack)
  170. - if( e.getCause!=null )
  171. .nested
  172. - displayException(e.getCause)
  173. #scalate-error
  174. - exception match
  175. - case e:InvalidSyntaxException =>
  176. - displayError( e.template, e.pos, e.brief)
  177. - case e:CompilerException =>
  178. - for ( error <- e.errors )
  179. - displayError(error.file, error.pos, error.message)
  180. - val o = error.original
  181. - if (o != null)
  182. .section.block
  183. = editLink(o.file, o.pos.line, o.pos.column)
  184. from generated #{shorten(o.file)} near line #{o.pos.line} col #{o.pos.line}
  185. - case e:Throwable =>
  186. - displayException(e)
  187. - case u =>
  188. .header.block
  189. %h1
  190. = errorMessage
  191. %p
  192. = u
  193. - catch
  194. - case e:Throwable=>
  195. - e.printStackTrace
  196. -# Fallback to a simple rendering of the error message
  197. .header.block
  198. %h1
  199. = errorMessage