Skip to content

Commit 7513b2c

Browse files
authored
Merge pull request #91 from simplelocalize/adjust-client-request
Adjust error handling
2 parents a324539 + 1d5cf79 commit 7513b2c

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

src/main/java/io/simplelocalize/cli/SimplelocalizeCliCommand.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,14 @@ private void trySendException(Exception exception)
512512
client.sendException(effectiveCommandConfiguration, exception);
513513
} catch (Exception ex)
514514
{
515-
log.error("Unable to send exception to SimpleLocalize, please contact us at [email protected]. {}", ex.getMessage());
515+
if (debug)
516+
{
517+
log.error("Unable to send exception", ex);
518+
} else
519+
{
520+
log.error("Unable to send exception to SimpleLocalize, please contact us at [email protected]. {}", ex.getMessage());
521+
}
522+
516523
if (ex instanceof InterruptedException)
517524
{
518525
Thread.currentThread().interrupt();

src/main/java/io/simplelocalize/cli/client/SimpleLocalizeClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private void throwOnError(HttpResponse<?> httpResponse)
178178
message = "Unknown error, HTTP Status: " + httpResponse.statusCode();
179179
}
180180
log.error("Request failed: {}", message);
181-
throw new ApiRequestException(message, httpResponse);
181+
throw new ApiRequestException(message);
182182
}
183183
}
184184

src/main/java/io/simplelocalize/cli/configuration/ConfigurationValidator.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
public final class ConfigurationValidator
1010
{
11-
private static final Logger log = LoggerFactory.getLogger(ConfigurationValidator.class);
12-
1311
public void validateExtractConfiguration(Configuration configuration)
1412
{
1513
validateIsNotEmptyOrNull(configuration.getApiKey(), "apiKey");
@@ -63,8 +61,8 @@ private void validateIsNotEmptyOrNull(String format, String argumentName)
6361

6462
if (StringUtils.isEmpty(format))
6563
{
66-
log.error("Missing '{}' value", argumentName);
67-
throw new ConfigurationException();
64+
String message = "Missing '%s' value".formatted(argumentName);
65+
throw new ConfigurationException(message);
6866
}
6967
}
7068
}
Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
package io.simplelocalize.cli.exception;
22

3-
import java.net.http.HttpRequest;
4-
import java.net.http.HttpResponse;
5-
import java.util.Optional;
6-
73
public class ApiRequestException extends RuntimeException
84
{
9-
10-
private final transient HttpResponse<?> httpResponse;
11-
12-
public ApiRequestException(String apiMessage, HttpResponse<?> httpResponse)
5+
public ApiRequestException(String apiMessage)
136
{
147
super(apiMessage);
15-
this.httpResponse = httpResponse;
16-
}
17-
18-
public HttpResponse<?> getHttpResponse()
19-
{
20-
return httpResponse;
21-
}
22-
23-
public HttpRequest getHttpRequest()
24-
{
25-
return Optional.ofNullable(httpResponse).map(HttpResponse::request).orElse(null);
268
}
279
}

0 commit comments

Comments
 (0)