From 6a9315a5da90877483891199ffd5fa61024b0a94 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 22 May 2025 17:44:48 +0500 Subject: [PATCH 1/2] Updated SteamApiException - statusCode exposed --- .../core/exception/SteamApiException.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/lukaspradel/steamapi/core/exception/SteamApiException.java b/src/main/java/com/lukaspradel/steamapi/core/exception/SteamApiException.java index 86f6574..98f8563 100644 --- a/src/main/java/com/lukaspradel/steamapi/core/exception/SteamApiException.java +++ b/src/main/java/com/lukaspradel/steamapi/core/exception/SteamApiException.java @@ -9,25 +9,35 @@ public enum Cause { } private String message; + private final Integer statusCode; public SteamApiException(String message) { super(message); + this.statusCode = 500; } public SteamApiException(String message, Throwable cause) { super(message, cause); + this.statusCode = 500; } + public SteamApiException(String message, Integer statusCode) { + super(message); + this.statusCode = statusCode; + } + public SteamApiException(Cause cause, Throwable exceptionCause) { super(exceptionCause); switch (cause) { case MAPPING: + this.statusCode = 400; this.message = "The JSON response could not be parsed or mapped to the designated POJO. The most likely cause for this is that" + " the Steam API itself changed. Check for newer versions of this library to compensate for this."; break; default: + this.statusCode = 500; this.message = "The Web API request failed due to an unexpected error: " + exceptionCause.getMessage(); } @@ -35,6 +45,8 @@ public SteamApiException(Cause cause, Throwable exceptionCause) { public SteamApiException(Cause cause, Integer statusCode) { + this.statusCode = statusCode; + switch (cause) { case HTTP_ERROR: this.message = "The Web API request failed (status code: " + statusCode + ")."; @@ -58,4 +70,8 @@ public String getMessage() { return this.message; } } + + public Integer getStatusCode() { + return statusCode; + } } From e7e32134e172b4d6ac2f51311b3f711b36a3c5b9 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 23 May 2025 13:13:58 +0500 Subject: [PATCH 2/2] Updated SteamApiKeyException - throws 400 status code by default --- .../steamapi/core/exception/SteamApiKeyException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/lukaspradel/steamapi/core/exception/SteamApiKeyException.java b/src/main/java/com/lukaspradel/steamapi/core/exception/SteamApiKeyException.java index b8c2e82..08d503a 100644 --- a/src/main/java/com/lukaspradel/steamapi/core/exception/SteamApiKeyException.java +++ b/src/main/java/com/lukaspradel/steamapi/core/exception/SteamApiKeyException.java @@ -5,6 +5,6 @@ public class SteamApiKeyException extends SteamApiException { private static final long serialVersionUID = 5154813503049374498L; public SteamApiKeyException(String message) { - super(message); + super(message, 400); } }