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