Commit c08cdc1 1 parent 4f7dc90 commit c08cdc1 Copy full SHA for c08cdc1
File tree 1 file changed +11
-0
lines changed
ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -78,8 +78,19 @@ public MLSdkAsyncHttpResponseHandler(
78
78
@ Override
79
79
public void onHeaders (SdkHttpResponse response ) {
80
80
SdkHttpFullResponse sdkResponse = (SdkHttpFullResponse ) response ;
81
+ List <String > errorsInHeader = sdkResponse .headers ().get ("x-amzn-ErrorType" );
82
+ boolean containsThrottlingException = errorsInHeader .stream ().anyMatch (str -> str .startsWith ("ThrottlingException" ));
81
83
log .debug ("received response headers: " + sdkResponse .headers ());
82
84
this .statusCode = sdkResponse .statusCode ();
85
+ if (containsThrottlingException ) {
86
+ actionListener
87
+ .onFailure (
88
+ new OpenSearchStatusException (
89
+ REMOTE_SERVICE_ERROR + "The request was denied due to request throttling." ,
90
+ RestStatus .fromCode (statusCode )
91
+ )
92
+ );
93
+ }
83
94
}
84
95
85
96
@ Override
You can’t perform that action at this time.
0 commit comments