All Downloads are FREE. Search and download functionalities are using the official Maven repository.

liquibase.precondition.ErrorPrecondition Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package liquibase.precondition;

import liquibase.changelog.DatabaseChangeLog;

public class ErrorPrecondition {
    private final Throwable cause;
    private final Precondition precondition;
    private final DatabaseChangeLog changeLog;


    public ErrorPrecondition(Throwable exception, DatabaseChangeLog changeLog, Precondition precondition) {
        this.cause = exception;
        this.changeLog = changeLog;
        this.precondition = precondition;
    }


    public Throwable getCause() {
        return cause;
    }

    public Precondition getPrecondition() {
        return precondition;
    }


    @Override
    public String toString() {
        Throwable cause = this.cause;
        while (cause.getCause() != null) {
            cause = cause.getCause();
        }

        String causeMessage = cause.getMessage();
        if (causeMessage == null) {
            causeMessage = this.cause.getMessage();
        }
        if (changeLog == null) {
            return causeMessage;
        } else {
            return changeLog +" : "+ precondition.toString()+" : "+causeMessage;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy