40 lines
989 B
Java
40 lines
989 B
Java
package org.gcube.resourcemanagement.manager.io.codeexceptions.deserializer;
|
|
|
|
import java.util.Objects;
|
|
|
|
import org.gcube.resourcemanagement.manager.io.codeexceptions.ErrorCode;
|
|
import org.gcube.resourcemanagement.manager.io.codeexceptions.SerializableErrorEntity;
|
|
|
|
/**
|
|
* Don't forget to comment!
|
|
*
|
|
* @author Manuele Simi (ISTI CNR)
|
|
*
|
|
*/
|
|
public class ErrorEntityManager {
|
|
|
|
private final SerializableErrorEntity entity;
|
|
/**
|
|
*
|
|
*/
|
|
public ErrorEntityManager(SerializableErrorEntity entity) {
|
|
this.entity = entity;
|
|
}
|
|
|
|
public boolean hasException() {
|
|
return Objects.nonNull(this.entity.getExceptionClass());
|
|
}
|
|
|
|
public <E extends Exception> E getException() {
|
|
return ExceptionDeserializer.deserialize(this.entity.getExceptionClass(),this.entity.getMessage());
|
|
}
|
|
|
|
public boolean hasErrorCode() {
|
|
return this.entity.getId() != -1;
|
|
}
|
|
|
|
public ErrorCode getErrorCode(){
|
|
return ErrorCodeDeserializer.deserialize(this.entity.getId(), this.entity.getMessage());
|
|
}
|
|
}
|