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

com.xlrit.gears.base.exception.BaseException Maven / Gradle / Ivy

There is a newer version: 1.17.6
Show newest version
package com.xlrit.gears.base.exception;

import java.time.OffsetDateTime;

import de.huxhorn.sulky.ulid.ULID;

public abstract class BaseException extends RuntimeException {
	private static final ULID ulid = new ULID();

	private final String id = ulid.nextULID();
	private final OffsetDateTime timestamp = OffsetDateTime.now();

	protected BaseException(Throwable cause) {
		super(getRootCause(cause).getMessage(), cause);
	}

	protected BaseException(String message, Throwable cause) {
		super(message, cause);
	}

	protected BaseException(String message) {
		super(message);
	}

	public String getId() {
		return id;
	}

	public OffsetDateTime getTimestamp() {
		return timestamp;
	}

	protected static Throwable getRootCause(Throwable throwable) {
		while (throwable.getCause() != null)
			throwable = throwable.getCause();
		return throwable;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy