Skip to content

Commit 24896bf

Browse files
committed
wrap exception into 5xx
Signed-off-by: Brian Flores <[email protected]>
1 parent 77f6e5b commit 24896bf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

plugin/src/main/java/org/opensearch/ml/action/undeploy/TransportUndeployModelsAction.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,15 @@ private void bulkSetModelIndexToUndeploy(
214214
log.debug("Successfully set the following modelId(s) to UNDEPLOY in index: {}", Arrays.toString(modelIds));
215215
listenerWithContextRestoration.onResponse(new MLUndeployModelsResponse(response));
216216
}, e -> {
217-
log.error("Failed to set the following modelId(s) to UNDEPLOY in index: {}", Arrays.toString(modelIds), e);
218-
listenerWithContextRestoration.onFailure(e);
217+
String modelsNotFoundMessage = String
218+
.format("Failed to set the following modelId(s) to UNDEPLOY in index: %s", Arrays.toString(modelIds));
219+
log.error(modelsNotFoundMessage, e);
220+
221+
OpenSearchStatusException exception = new OpenSearchStatusException(
222+
modelsNotFoundMessage + e.getMessage(),
223+
RestStatus.INTERNAL_SERVER_ERROR
224+
);
225+
listenerWithContextRestoration.onFailure(exception);
219226
});
220227

221228
client.bulk(bulkUpdateRequest, bulkResponseListener);

0 commit comments

Comments
 (0)