Skip to content

Commit a41b0ce

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

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
@@ -237,8 +237,15 @@ private void bulkSetModelIndexToUndeploy(
237237
log.debug("Successfully set the following modelId(s) to UNDEPLOY in index: {}", Arrays.toString(modelIds));
238238
listenerWithContextRestoration.onResponse(new MLUndeployModelsResponse(response));
239239
}, e -> {
240-
log.error("Failed to set the following modelId(s) to UNDEPLOY in index: {}", Arrays.toString(modelIds), e);
241-
listenerWithContextRestoration.onFailure(e);
240+
String modelsNotFoundMessage = String
241+
.format("Failed to set the following modelId(s) to UNDEPLOY in index: %s", Arrays.toString(modelIds));
242+
log.error(modelsNotFoundMessage, e);
243+
244+
OpenSearchStatusException exception = new OpenSearchStatusException(
245+
modelsNotFoundMessage + e.getMessage(),
246+
RestStatus.INTERNAL_SERVER_ERROR
247+
);
248+
listenerWithContextRestoration.onFailure(exception);
242249
});
243250

244251
client.bulk(bulkUpdateRequest, bulkResponseListener);

0 commit comments

Comments
 (0)