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

de.tum.in.test.api.util.UnexpectedExceptionError Maven / Gradle / Ivy

There is a newer version: 1.13.0
Show newest version
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 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 getOriginalType() {
		return originalType;
	}

	public static UnexpectedExceptionError wrap(Throwable t) {
		if (t == null)
			return null;
		return new UnexpectedExceptionError(t);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy