de.tum.in.test.api.util.UnexpectedExceptionError Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of artemis-java-test-sandbox Show documentation
Show all versions of artemis-java-test-sandbox Show documentation
The Artemis Java Test Sandbox. A JUnit 5 Extension for secure Artemis Java Testing.
package de.tum.in.test.api.util;
import static de.tum.in.test.api.internal.BlacklistedInvoker.invoke;
import static de.tum.in.test.api.internal.sanitization.ThrowableSanitizer.sanitize;
import org.apiguardian.api.API;
import org.apiguardian.api.API.Status;
@API(status = Status.MAINTAINED)
public final class UnexpectedExceptionError extends Error {
private static final long serialVersionUID = 1L;
private final Class extends Throwable> originalType;
private UnexpectedExceptionError(Throwable cause) {
super(invoke(cause::toString), sanitize(invoke(cause::getCause)), true, true);
originalType = cause.getClass();
setStackTrace(invoke(cause::getStackTrace));
for (Throwable sup : invoke(cause::getSuppressed))
addSuppressed(sanitize(sup));
}
public Class extends Throwable> getOriginalType() {
return originalType;
}
public static UnexpectedExceptionError wrap(Throwable t) {
if (t == null)
return null;
return new UnexpectedExceptionError(t);
}
}