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

net.serenitybdd.core.exceptions.SerenityManagedException Maven / Gradle / Ivy

There is a newer version: 4.2.1
Show newest version
package net.serenitybdd.core.exceptions;


import org.openqa.selenium.WebDriverException;

public class SerenityManagedException extends RuntimeException {

    private final String detailedMessage;
    private final StackTraceElement[] stackTrace;
    private final Throwable cause;
    private final Class exceptionClass;


    public static Throwable detachedCopyOf(Throwable testErrorException) {
        if (!(testErrorException instanceof WebDriverException)) {
            return testErrorException;
        } else if (testErrorException instanceof SerenityManagedException) {
            return testErrorException;
        } else {
            return new SerenityManagedException(testErrorException);
        }
    }


    public SerenityManagedException(Throwable testErrorException) {
        super(testErrorException);
        this.detailedMessage = testErrorException.getMessage();
        this.stackTrace = testErrorException.getStackTrace();
        this.cause = testErrorException.getCause();
        this.exceptionClass = testErrorException.getClass();
    }

    public SerenityManagedException(String message, Throwable testErrorException) {
        super(testErrorException);
        this.detailedMessage = message;
        this.stackTrace = testErrorException.getStackTrace();
        this.cause =  testErrorException.getCause();
        this.exceptionClass = testErrorException.getClass();
    }


    @Override
    public String getMessage() {
        return detailedMessage;
    }

    @Override
    public StackTraceElement[] getStackTrace() {
        return stackTrace.clone();
    }

    @Override
    public Throwable getCause() {
        return cause;
    }

    public Class getExceptionClass() {
        return exceptionClass;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy