EvaluationException.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright 2004-2008 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springframework.expression;
  17. /**
  18. * Base class for exceptions occurring during expression parsing and evaluation.
  19. *
  20. * @author Andy Clement
  21. */
  22. public class EvaluationException extends Exception {
  23. /**
  24. * The expression string.
  25. */
  26. private String expressionString;
  27. /**
  28. * Creates a new expression exception. The expressionString field should be set by a later call to
  29. * setExpressionString().
  30. *
  31. * @param cause the underlying cause of this exception
  32. */
  33. public EvaluationException(Throwable cause) {
  34. super(cause);
  35. }
  36. /**
  37. * Creates a new expression parsing exception.
  38. *
  39. * @param expressionString the expression string that could not be parsed
  40. * @param cause the underlying cause of this exception
  41. */
  42. public EvaluationException(String expressionString, Throwable cause) {
  43. this(expressionString, "Exception occurred whilst handling '" + expressionString + "'", cause);
  44. }
  45. /**
  46. * Creates a new expression exception.
  47. *
  48. * @param expressionString the expression string
  49. * @param message a descriptive message
  50. * @param cause the underlying cause of this exception
  51. */
  52. public EvaluationException(String expressionString, String message, Throwable cause) {
  53. super(message, cause);
  54. this.expressionString = expressionString;
  55. }
  56. /**
  57. * Creates a new expression exception.
  58. *
  59. * @param expressionString the expression string
  60. * @param message a descriptive message
  61. */
  62. public EvaluationException(String expressionString, String message) {
  63. super(message);
  64. this.expressionString = expressionString;
  65. }
  66. /**
  67. * Creates a new expression exception. The expressionString field should be set by a later call to
  68. * setExpressionString().
  69. *
  70. * @param message a descriptive message
  71. */
  72. public EvaluationException(String message) {
  73. super(message);
  74. }
  75. /**
  76. * Set the expression string, called on exceptions where the expressionString is not known at the time of exception
  77. * creation.
  78. *
  79. * @param expressionString the expression string
  80. */
  81. protected final void setExpressionString(String expressionString) {
  82. this.expressionString = expressionString;
  83. }
  84. /**
  85. * @return the expression string
  86. */
  87. public final String getExpressionString() {
  88. return expressionString;
  89. }
  90. }