1 package liquibase.exception; 2 3 import liquibase.changelog.ChangeSet; 4 5 public class MigrationFailedException extends LiquibaseException { 6 7 private static final long serialVersionUID = 1L; 8 private ChangeSet failedChangeSet; 9 10 public MigrationFailedException() { 11 } 12 13 public MigrationFailedException(ChangeSet failedChangeSet, String message) { 14 super(message); 15 this.failedChangeSet = failedChangeSet; 16 } 17 18 public MigrationFailedException(ChangeSet failedChangeSet, String message, Throwable cause) { 19 super(message, cause); 20 this.failedChangeSet = failedChangeSet; 21 } 22 23 public MigrationFailedException(ChangeSet failedChangeSet, Throwable cause) { 24 super(cause); 25 this.failedChangeSet = failedChangeSet; 26 } 27 28 @Override 29 public String getMessage() { 30 String message = "Migration failed"; 31 if (failedChangeSet != null) { 32 message += " for change set " + failedChangeSet.toString(false); 33 } 34 message += ":\n Reason: " + super.getMessage(); 35 Throwable cause = this.getCause(); 36 while (cause != null) { 37 message += ":\n Caused By: " + cause.getMessage(); 38 cause = cause.getCause(); 39 } 40 41 return message; 42 } 43 }