1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.xml.parsers;
  6. /**
  7. * Thrown when a problem with configuration with the Parser Factories
  8. * exists. This error will typically be thrown when the class of a
  9. * parser factory specified in the system properties cannot be found
  10. * or instantiated.
  11. *
  12. * @since JAXP 1.0
  13. * @version 1.0
  14. */
  15. public class FactoryConfigurationError extends Error {
  16. private Exception exception;
  17. /**
  18. * Create a new <code>FactoryConfigurationError</code> with no
  19. * detail mesage.
  20. */
  21. public FactoryConfigurationError() {
  22. super();
  23. this.exception = null;
  24. }
  25. /**
  26. * Create a new <code>FactoryConfigurationError</code> with
  27. * the <code>String </code> specified as an error message.
  28. *
  29. * @param msg The error message for the exception.
  30. */
  31. public FactoryConfigurationError(String msg) {
  32. super(msg);
  33. this.exception = null;
  34. }
  35. /**
  36. * Create a new <code>FactoryConfigurationError</code> with a
  37. * given <code>Exception</code> base cause of the error.
  38. *
  39. * @param e The exception to be encapsulated in a
  40. * FactoryConfigurationError.
  41. */
  42. public FactoryConfigurationError(Exception e) {
  43. super(e.toString());
  44. this.exception = e;
  45. }
  46. /**
  47. * Create a new <code>FactoryConfigurationError</code> with the
  48. * given <code>Exception</code> base cause and detail message.
  49. *
  50. * @param e The exception to be encapsulated in a
  51. * FactoryConfigurationError
  52. * @param msg The detail message.
  53. * @param e The exception to be wrapped in a FactoryConfigurationError
  54. */
  55. public FactoryConfigurationError(Exception e, String msg) {
  56. super(msg);
  57. this.exception = e;
  58. }
  59. /**
  60. * Return the message (if any) for this error . If there is no
  61. * message for the exception and there is an encapsulated
  62. * exception then the message of that exception, if it exists will be
  63. * returned. Else the name of the encapsulated exception will be
  64. * returned.
  65. *
  66. * @return The error message.
  67. */
  68. public String getMessage () {
  69. String message = super.getMessage ();
  70. if (message == null && exception != null) {
  71. return exception.getMessage();
  72. }
  73. return message;
  74. }
  75. /**
  76. * Return the actual exception (if any) that caused this exception to
  77. * be raised.
  78. *
  79. * @return The encapsulated exception, or null if there is none.
  80. */
  81. public Exception getException () {
  82. return exception;
  83. }
  84. }