Skip to content

Commit

Permalink
Merge pull request #1084 from /issues/1083-PowerAuthClientException-NPE
Browse files Browse the repository at this point in the history
Fix #1083: PowerAuthClientException#getPowerAuthError is nullable
  • Loading branch information
banterCZ authored Oct 20, 2023
2 parents c897dae + cf19074 commit 56229e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.wultra.security.powerauth.client.model.error;

import java.io.Serial;
import java.util.Optional;

/**
* PowerAuth client exception.
Expand All @@ -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;
}

/**
Expand All @@ -43,6 +45,7 @@ public PowerAuthClientException() {
*/
public PowerAuthClientException(String message) {
super(message);
this.powerAuthError = null;
}

/**
Expand All @@ -52,6 +55,7 @@ public PowerAuthClientException(String message) {
*/
public PowerAuthClientException(String message, Throwable cause) {
super(message, cause);
this.powerAuthError = null;
}

/**
Expand All @@ -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<PowerAuthError> getPowerAuthError() {
return Optional.ofNullable(powerAuthError);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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, [email protected]
*/
public class PowerAuthError {
public class PowerAuthError implements Serializable {

@Serial
private static final long serialVersionUID = 3172664961204150558L;

private String code;
private String message;
Expand Down

0 comments on commit 56229e6

Please sign in to comment.