-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw errors on model deletion failures (#834)
Throws errors on model deletion. Previously we were indicating failure, but returning 200 response codes. This changes that to throw exceptions with the correct response code. Signed-off-by: John Mazanec <[email protected]>
- Loading branch information
1 parent
303d811
commit 5c3bf53
Showing
10 changed files
with
114 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/org/opensearch/knn/common/exception/DeleteModelWhenInTrainStateException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.common.exception; | ||
|
||
import org.opensearch.OpenSearchException; | ||
import org.opensearch.common.logging.LoggerMessageFormat; | ||
import org.opensearch.rest.RestStatus; | ||
|
||
/** | ||
* Exception thrown when a model is deleted while it is in the training state. The RestStatus associated with this | ||
* exception should be a {@link RestStatus#CONFLICT} because the request cannot be deleted due to the model being in | ||
* the training state. | ||
*/ | ||
public class DeleteModelWhenInTrainStateException extends OpenSearchException { | ||
/** | ||
* Constructor | ||
* | ||
* @param msg detailed exception message | ||
* @param args arguments of the message | ||
*/ | ||
public DeleteModelWhenInTrainStateException(String msg, Object... args) { | ||
super(LoggerMessageFormat.format(msg, args)); | ||
} | ||
|
||
@Override | ||
public RestStatus status() { | ||
return RestStatus.CONFLICT; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.