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.dbcp;
  17. /**
  18. * <p>Subclass of <code>RuntimeException</code> that can be used to wrap
  19. * a <code>SQLException</code> using the "root cause" pattern of JDK 1.4
  20. * exceptions, but without requiring a 1.4 runtime environment.</p>
  21. *
  22. * @author Jonathan Fuerth
  23. * @author Dan Fraser
  24. * @version $Revision: 1.5 $ $Date: 2004/02/28 11:48:04 $
  25. *
  26. * @deprecated This will be removed in a future version of DBCP.
  27. **/
  28. public class DbcpException extends RuntimeException {
  29. // ----------------------------------------------------------- Constructors
  30. /**
  31. * Construct a new runtime exception with <code>null</code> as its
  32. * detail message.
  33. */
  34. public DbcpException() {
  35. super();
  36. }
  37. /**
  38. * Construct a new runtime exception with the specified detail message.
  39. *
  40. * @param message The detail message for this exception
  41. */
  42. public DbcpException(String message) {
  43. this(message, null);
  44. }
  45. /**
  46. * Construct a new runtime exception with the specified detail message
  47. * and cause.
  48. *
  49. * @param message The detail message for this exception
  50. * @param cause The root cause for this exception
  51. */
  52. public DbcpException(String message, Throwable cause) {
  53. super(message);
  54. this.cause = cause;
  55. }
  56. /**
  57. * Construct a new runtime exception with the specified cause and a
  58. * detail message of <code>(cause == null ? null : cause.toString())</code>.
  59. *
  60. * @param cause The root cause for this exception
  61. */
  62. public DbcpException(Throwable cause) {
  63. super((cause == null) ? (String) null : cause.toString());
  64. this.cause = cause;
  65. }
  66. // ----------------------------------------------------- Instance Variables
  67. /**
  68. * The root cause of this exception (typically an
  69. * <code>SQLException</code> but this is not required).
  70. */
  71. protected Throwable cause = null;
  72. // --------------------------------------------------------- Public Methods
  73. /**
  74. * Return the root cause of this exception (if any).
  75. */
  76. public Throwable getCause() {
  77. return (this.cause);
  78. }
  79. }