Extend ExceptionInfo with map info + EntityNotFound info (#1901)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-10-17 16:51:29 +03:00
committed by GitHub
parent 331cf8e692
commit 60ee383158
5 changed files with 75 additions and 110 deletions

View File

@@ -9,65 +9,94 @@
*/
package org.eclipse.hawkbit.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.util.Map;
/**
* Generic Custom Exception to wrap the Runtime and checked exception
*/
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class AbstractServerRtException extends RuntimeException {
@Serial
private static final long serialVersionUID = 1L;
private final SpServerError error;
private final Map<String, Object> info;
/**
* Parameterized constructor.
*
* @param error
* detail
* @param error detail
*/
protected AbstractServerRtException(final SpServerError error) {
super(error.getMessage());
this.error = error;
this.info = null;
}
/**
* Parameterized constructor.
*
* @param message
* custom error message
* @param error
* detail
* @param message custom error message
* @param error detail
*/
protected AbstractServerRtException(final String message, final SpServerError error) {
this(message, error, (Map<String, Object>) null);
}
/**
* Parameterized constructor.
*
* @param message custom error message
* @param error detail
*/
protected AbstractServerRtException(final String message, final SpServerError error, final Map<String, Object> info) {
super(message);
this.error = error;
this.info = info;
}
/**
* Parameterized constructor.
*
* @param message
* custom error message
* @param error
* detail
* @param cause
* of the exception
* @param message custom error message
* @param error detail
* @param cause of the exception
*/
protected AbstractServerRtException(final String message, final SpServerError error, final Throwable cause) {
super(message, cause);
this.error = error;
this.info = null;
}
/**
* Parameterized constructor.
*
* @param error
* detail
* @param cause
* of the exception
* @param error detail
* @param cause of the exception
*/
protected AbstractServerRtException(final SpServerError error, final Throwable cause) {
super(error.getMessage(), cause);
this.error = error;
this.info = null;
}
/**
* Parameterized constructor.
*
* @param message custom error message
* @param error detail
* @param cause of the exception
*/
protected AbstractServerRtException(final String message, final SpServerError error, final Throwable cause, final Map<String, Object> info) {
super(message, cause);
this.error = error;
this.info = info;
}
/**