Skip to content

Commit 01c5e7f

Browse files
committed
CM-2345: Extracted error message into resources.
1 parent 21c94f9 commit 01c5e7f

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

comet-java-client/src/main/java/ml/comet/experiment/impl/RestApiClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
import static ml.comet.experiment.impl.constants.QueryParamName.TYPE;
117117
import static ml.comet.experiment.impl.constants.QueryParamName.WORKSPACE_NAME;
118118
import static ml.comet.experiment.impl.http.ConnectionUtils.checkResponseStatus;
119+
import static ml.comet.experiment.impl.resources.LogMessages.NO_RESPONSE_RETURNED_BY_REMOTE_ENDPOINT;
120+
import static ml.comet.experiment.impl.resources.LogMessages.getString;
119121
import static ml.comet.experiment.impl.utils.RestApiUtils.artifactDownloadAssetParams;
120122
import static ml.comet.experiment.impl.utils.RestApiUtils.artifactVersionDetailsParams;
121123
import static ml.comet.experiment.impl.utils.RestApiUtils.artifactVersionFilesParams;
@@ -497,15 +499,15 @@ private Single<RestApiResponse> singleFromSyncPostWithRetriesEmptyBody(@NonNull
497499
return this.connection.sendPostWithRetries(JsonUtils.toJson(payload), endpoint, true)
498500
.map(body -> Single.just(new RestApiResponse(200, body)))
499501
.orElse(Single.error(new CometApiException(
500-
String.format("No response was returned by endpoint: %s", endpoint))));
502+
getString(NO_RESPONSE_RETURNED_BY_REMOTE_ENDPOINT, endpoint))));
501503
}
502504

503505
private Single<RestApiResponse> singleFromSyncGetWithRetries(@NonNull String endpoint,
504506
@NonNull Map<QueryParamName, String> params) {
505507
return this.connection.sendGetWithRetries(endpoint, params, true)
506508
.map(body -> Single.just(new RestApiResponse(200, body)))
507509
.orElse(Single.error(new CometApiException(
508-
String.format("No response was returned by endpoint: %s", endpoint))));
510+
getString(NO_RESPONSE_RETURNED_BY_REMOTE_ENDPOINT, endpoint))));
509511
}
510512

511513
private <T> Single<T> singleFromSyncGetWithRetries(@NonNull String endpoint,

comet-java-client/src/main/java/ml/comet/experiment/impl/resources/LogMessages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public class LogMessages {
9898
public static final String FAILED_TO_UPDATE_REGISTRY_MODEL_VERSION = "FAILED_TO_UPDATE_REGISTRY_MODEL_VERSION";
9999
public static final String REGISTRY_MODEL_VERSION_NOT_FOUND = "REGISTRY_MODEL_VERSION_NOT_FOUND";
100100
public static final String FAILED_TO_DELETE_REGISTRY_MODEL = "FAILED_TO_DELETE_REGISTRY_MODEL";
101+
public static final String NO_RESPONSE_RETURNED_BY_REMOTE_ENDPOINT = "NO_RESPONSE_RETURNED_BY_REMOTE_ENDPOINT";
101102

102103

103104
/**

comet-java-client/src/main/resources/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,4 @@ FAILED_TO_UPDATE_REGISTRY_MODEL=Failed to update registry model '%s/%s' with dat
8383
FAILED_TO_UPDATE_REGISTRY_MODEL_VERSION=Failed to update registry model's version '%s/%s:%s' with data: '%s'.
8484
REGISTRY_MODEL_VERSION_NOT_FOUND=Version '%s' of the registry model '%s/%s' is not found.
8585
FAILED_TO_DELETE_REGISTRY_MODEL=Failed to delete registry model '%s/%s'.
86+
NO_RESPONSE_RETURNED_BY_REMOTE_ENDPOINT=No response was returned by endpoint '%s'

0 commit comments

Comments
 (0)