1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation
  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.apache.commons.jxpath;
  17. /**
  18. * Thrown when a problem with configuration with the JXPathContextFactories
  19. * exists. This error will typically be thrown when the class of a
  20. * factory specified in the system properties cannot be found
  21. * or instantiated.
  22. *
  23. * @author Dmitri Plotnikov
  24. * @version $Revision: 1.5 $ $Date: 2004/02/29 14:17:42 $
  25. */
  26. public class JXPathContextFactoryConfigurationError extends Error {
  27. /** @serial */
  28. private Exception exception;
  29. /**
  30. * Create a new <code>JXPathContextFactoryConfigurationError</code> with no
  31. * detail mesage.
  32. */
  33. public JXPathContextFactoryConfigurationError() {
  34. super();
  35. this.exception = null;
  36. }
  37. /**
  38. * Create a new <code>JXPathContextFactoryConfigurationError</code> with
  39. * the <code>String </code> specified as an error message.
  40. *
  41. * @param msg The error message for the exception.
  42. */
  43. public JXPathContextFactoryConfigurationError(String msg) {
  44. super(msg);
  45. this.exception = null;
  46. }
  47. /**
  48. * Create a new <code>JXPathContextFactoryConfigurationError</code> with a
  49. * given <code>Exception</code> base cause of the error.
  50. *
  51. * @param e The exception to be encapsulated in a
  52. * JXPathContextFactoryConfigurationError.
  53. */
  54. public JXPathContextFactoryConfigurationError(Exception e) {
  55. super(e.toString());
  56. this.exception = e;
  57. }
  58. /**
  59. * Create a new <code>JXPathContextFactoryConfigurationError</code> with the
  60. * given <code>Exception</code> base cause and detail message.
  61. *
  62. * @param e The exception to be encapsulated in a
  63. * JXPathContextFactoryConfigurationError
  64. * @param msg The detail message.
  65. */
  66. public JXPathContextFactoryConfigurationError(Exception e, String msg) {
  67. super(msg);
  68. this.exception = e;
  69. }
  70. /**
  71. * Return the message (if any) for this error . If there is no
  72. * message for the exception and there is an encapsulated
  73. * exception then the message of that exception will be returned.
  74. *
  75. * @return The error message.
  76. */
  77. public String getMessage () {
  78. String message = super.getMessage ();
  79. if (message == null && exception != null) {
  80. return exception.getMessage();
  81. }
  82. return message;
  83. }
  84. /**
  85. * Return the actual exception (if any) that caused this exception to
  86. * be raised.
  87. *
  88. * @return The encapsulated exception, or null if there is none.
  89. */
  90. public Exception getException () {
  91. return exception;
  92. }
  93. }