1 package de.fhdw.wtf.persistence.exception;
2
3 import java.sql.SQLException;
4
5 /**
6 * A class to represent a supertype for all kinds of persistence Exceptions, which might occur during accessing the
7 * Database.
8 *
9 */
10 public abstract class PersistenceException extends Exception {
11
12 /**
13 * The original SQL Exception, which causes the instantiation of this Persistence Exception.
14 */
15 private final SQLException nestedException;
16
17 /**
18 * Needed for serialization.
19 */
20 private static final long serialVersionUID = 1L;
21
22 /**
23 * Protected supertype constructor for a new Persistence Exception.
24 *
25 * @param message
26 * A message describing the Error must be declared by each subtype
27 * @param nestedException
28 * The original SQL Exception, causing the Error, to determine the origin of the Persistence Exception
29 */
30 protected PersistenceException(final String message, final SQLException nestedException) {
31 super(message);
32 this.nestedException = nestedException;
33 }
34
35 @Override
36 public void printStackTrace() {
37 super.printStackTrace();
38 if (this.nestedException != null) {
39 this.nestedException.printStackTrace();
40 }
41 }
42
43 }