diff --git a/powerauth-client-model/src/main/java/com/wultra/security/powerauth/client/model/error/PowerAuthClientException.java b/powerauth-client-model/src/main/java/com/wultra/security/powerauth/client/model/error/PowerAuthClientException.java index 2ecbbf3a3..8655aa443 100644 --- a/powerauth-client-model/src/main/java/com/wultra/security/powerauth/client/model/error/PowerAuthClientException.java +++ b/powerauth-client-model/src/main/java/com/wultra/security/powerauth/client/model/error/PowerAuthClientException.java @@ -18,6 +18,7 @@ package com.wultra.security.powerauth.client.model.error; import java.io.Serial; +import java.util.Optional; /** * PowerAuth client exception. @@ -29,12 +30,13 @@ public class PowerAuthClientException extends Exception { @Serial private static final long serialVersionUID = -4721271754602015511L; - private PowerAuthError powerAuthError; + private final PowerAuthError powerAuthError; /** * Default constructor. */ public PowerAuthClientException() { + this.powerAuthError = null; } /** @@ -43,6 +45,7 @@ public PowerAuthClientException() { */ public PowerAuthClientException(String message) { super(message); + this.powerAuthError = null; } /** @@ -52,6 +55,7 @@ public PowerAuthClientException(String message) { */ public PowerAuthClientException(String message, Throwable cause) { super(message, cause); + this.powerAuthError = null; } /** @@ -69,8 +73,8 @@ public PowerAuthClientException(String message, Throwable cause, PowerAuthError * Get the PowerAuth error object. * @return PowerAuth error object. */ - public PowerAuthError getPowerAuthError() { - return powerAuthError; + public Optional getPowerAuthError() { + return Optional.ofNullable(powerAuthError); } } \ No newline at end of file diff --git a/powerauth-client-model/src/main/java/com/wultra/security/powerauth/client/model/error/PowerAuthError.java b/powerauth-client-model/src/main/java/com/wultra/security/powerauth/client/model/error/PowerAuthError.java index eca486e43..8f97eceea 100644 --- a/powerauth-client-model/src/main/java/com/wultra/security/powerauth/client/model/error/PowerAuthError.java +++ b/powerauth-client-model/src/main/java/com/wultra/security/powerauth/client/model/error/PowerAuthError.java @@ -17,12 +17,18 @@ */ package com.wultra.security.powerauth.client.model.error; +import java.io.Serial; +import java.io.Serializable; + /** * Class representing a PowerAuth error. * * @author Petr Dvorak, petr@wultra.com */ -public class PowerAuthError { +public class PowerAuthError implements Serializable { + + @Serial + private static final long serialVersionUID = 3172664961204150558L; private String code; private String message;