From 9e3e12a08bfcc556e1538c804d62ad8859a371de Mon Sep 17 00:00:00 2001 From: Thilo Schwarz Date: Sun, 13 Apr 2025 19:27:21 +0200 Subject: [PATCH] Refactor constructor to explicitly throw IllegalArgumentException Updated the constructor in CfBasicHttpClient to include explicit throws for IllegalArgumentException. This enhances clarity and ensures the method signature reflects the potential for exceptions. Minor formatting adjustments were also made for improved code readability. --- .../java/codes/thischwa/cf/CfBasicHttpClient.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/codes/thischwa/cf/CfBasicHttpClient.java b/src/main/java/codes/thischwa/cf/CfBasicHttpClient.java index 4a87f8e..9f56203 100644 --- a/src/main/java/codes/thischwa/cf/CfBasicHttpClient.java +++ b/src/main/java/codes/thischwa/cf/CfBasicHttpClient.java @@ -38,14 +38,18 @@ abstract class CfBasicHttpClient { private final ObjectMapper objectMapper; - CfBasicHttpClient(String baseUrl, String authEmail, String authKey) { - if (baseUrl == null || baseUrl.isBlank()) { + CfBasicHttpClient(String baseUrl, String authEmail, String authKey) throws IllegalArgumentException + { + if (baseUrl == null || baseUrl.isBlank()) + { throw new IllegalArgumentException("Base URL must not be null or blank!"); } - if (authEmail == null || authEmail.isBlank()) { + if (authEmail == null || authEmail.isBlank()) + { throw new IllegalArgumentException("Authentication email must not be null or blank!"); } - if (authKey == null || authKey.isBlank()) { + if (authKey == null || authKey.isBlank()) + { throw new IllegalArgumentException("Authentication key must not be null or blank!"); } this.baseUrl = baseUrl;