| 1 | |
package liquibase.precondition.core; |
| 2 | |
|
| 3 | |
import liquibase.changelog.DatabaseChangeLog; |
| 4 | |
import liquibase.precondition.Precondition; |
| 5 | |
|
| 6 | |
public class ErrorPrecondition { |
| 7 | |
private Throwable cause; |
| 8 | |
private Precondition precondition; |
| 9 | |
private DatabaseChangeLog changeLog; |
| 10 | |
|
| 11 | 0 | public ErrorPrecondition(Throwable exception, DatabaseChangeLog changeLog, Precondition precondition) { |
| 12 | 0 | this.cause = exception; |
| 13 | 0 | this.changeLog = changeLog; |
| 14 | 0 | this.precondition = precondition; |
| 15 | 0 | } |
| 16 | |
|
| 17 | |
public Throwable getCause() { |
| 18 | 0 | return cause; |
| 19 | |
} |
| 20 | |
|
| 21 | |
public Precondition getPrecondition() { |
| 22 | 0 | return precondition; |
| 23 | |
} |
| 24 | |
|
| 25 | |
@Override |
| 26 | |
public String toString() { |
| 27 | 0 | Throwable cause = this.cause; |
| 28 | 0 | while (cause.getCause() != null) { |
| 29 | 0 | cause = cause.getCause(); |
| 30 | |
} |
| 31 | |
|
| 32 | 0 | String causeMessage = cause.getMessage(); |
| 33 | 0 | if (changeLog == null) { |
| 34 | 0 | return causeMessage; |
| 35 | |
} else { |
| 36 | 0 | return changeLog.toString() + " : " + causeMessage; |
| 37 | |
} |
| 38 | |
} |
| 39 | |
} |