01: package liquibase.exception;
02:
03: import liquibase.ChangeSet;
04:
05: public class MigrationFailedException extends LiquibaseException {
06:
07: private static final long serialVersionUID = 1L;
08: private ChangeSet failedChangeSet;
09:
10: public MigrationFailedException() {
11: }
12:
13: public MigrationFailedException(ChangeSet failedChangeSet,
14: String message) {
15: super (message);
16: this .failedChangeSet = failedChangeSet;
17: }
18:
19: public MigrationFailedException(ChangeSet failedChangeSet,
20: String message, Throwable cause) {
21: super (message, cause);
22: this .failedChangeSet = failedChangeSet;
23: }
24:
25: public MigrationFailedException(ChangeSet failedChangeSet,
26: Throwable cause) {
27: super (cause);
28: this .failedChangeSet = failedChangeSet;
29: }
30:
31: public String getMessage() {
32: String message = "Migration failed";
33: if (failedChangeSet != null) {
34: message += " for change set "
35: + failedChangeSet.toString(false);
36: }
37: message += ":\n Reason: " + super .getMessage();
38: Throwable cause = this .getCause();
39: while (cause != null) {
40: message += ":\n Caused By: " + cause.getMessage();
41: cause = cause.getCause();
42: }
43:
44: return message;
45: }
46: }
|