PageRenderTime 28ms CodeModel.GetById 13ms app.highlight 10ms RepoModel.GetById 2ms app.codeStats 0ms

/scalate-core/src/main/scala/org/fusesource/scalate/TemplateException.scala

http://github.com/scalate/scalate
Scala | 75 lines | 34 code | 15 blank | 26 comment | 3 complexity | f491deff82cdbf57bb0f0e76f7de890e 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 */
18package org.fusesource.scalate
19
20import org.fusesource.scalate.support.CompilerError
21
22import scala.util.control.NoStackTrace
23import scala.util.parsing.input.{ NoPosition, Position }
24
25/**
26 * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
27 */
28class TemplateException(
29  message: String,
30  cause: Throwable) extends RuntimeException(message, cause) {
31
32  def this(message: String) {
33    this(message, null)
34  }
35}
36
37/**
38 * Indicates a syntax error trying to parse the template
39 */
40class InvalidSyntaxException(
41  val brief: String,
42  val pos: Position = NoPosition) extends TemplateException(brief + " at " + pos) {
43
44  var source: TemplateSource = _
45
46  def template: String = if (source != null) source.uri else null
47
48}
49
50/**
51 * Indicates a Scala compiler error occurred when converting the template into bytecode
52 */
53class CompilerException(
54  msg: String,
55  val errors: List[CompilerError]) extends TemplateException(msg)
56
57class NoValueSetException(
58  val attribute: String) extends TemplateException("The value for '" + attribute + "' was not set")
59
60class NoFormParameterException(
61  val parameter: String) extends TemplateException("The form parameter '" + parameter + "' was not set")
62
63class NoSuchViewException(
64  val model: AnyRef,
65  val view: String) extends TemplateException("No '" + view +
66  "' view template could be found for model object '" + model + "' of type: " + model.getClass.getCanonicalName)
67
68class NoSuchFilterException(
69  val filter: String) extends TemplateException("No '" + filter + "' filter available.")
70
71class NoInjectionException(
72  val injectClass: Class[_]) extends TemplateException("Could not inject type  '" + injectClass + "' was not set")
73
74class StaleCacheEntryException(
75  source: TemplateSource) extends TemplateException("The compiled template for " + source + " needs to get recompiled") with NoStackTrace