[FEAT] add FailException adding exception context to permit better display of error in the future
This commit is contained in:
parent
54d4c420f9
commit
007003394a
@ -1,19 +1,34 @@
|
|||||||
package org.kar.archidata.exception;
|
package org.kar.archidata.exception;
|
||||||
|
|
||||||
|
import org.kar.archidata.api.DataResource;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
public class FailException extends Exception {
|
public class FailException extends Exception {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(DataResource.class);
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
public final Response.Status status;
|
public final Response.Status status;
|
||||||
|
public final Exception exception;
|
||||||
|
|
||||||
public FailException(final Response.Status status, final String message) {
|
public FailException(final Response.Status status, final String message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
this.exception = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FailException(final Response.Status status, final String message, final Exception ex) {
|
||||||
|
super(message);
|
||||||
|
this.status = status;
|
||||||
|
this.exception = ex;
|
||||||
|
ex.printStackTrace();
|
||||||
|
LOGGER.error("Generate Fail exception with exceptionData: {}", ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FailException(final String message) {
|
public FailException(final String message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.status = Response.Status.BAD_REQUEST;
|
this.status = Response.Status.BAD_REQUEST;
|
||||||
|
this.exception = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user