Handle null exceptions in the response with Optional.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@160525 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b6b7e25d32
commit
265dca22df
|
@ -13,7 +13,7 @@ public class ResponseFromResourceRegistry {
|
|||
private boolean success = false;
|
||||
|
||||
private String message;
|
||||
|
||||
|
||||
protected ResponseFromResourceRegistry() {}
|
||||
|
||||
public boolean wasSuccessful() {return success;}
|
||||
|
@ -31,8 +31,8 @@ public class ResponseFromResourceRegistry {
|
|||
* @return the exception
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <E extends Exception> E getException() {return success? null: (E) new Exception();}
|
||||
|
||||
|
||||
public <E extends Exception> Optional<E> getException() {
|
||||
return Optional.ofNullable(success? null: (E) new Exception());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue