Skip to content

Commit

Permalink
Wrapping exceptions.
Browse files Browse the repository at this point in the history
Signed-off-by: AWSHurneyt <[email protected]>
  • Loading branch information
AWSHurneyt committed Jul 18, 2024
1 parent ca5a54a commit c3f386e
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.OpenSearchException;
import org.opensearch.OpenSearchStatusException;
import org.opensearch.common.UUIDs;
import org.opensearch.commons.authuser.User;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
Expand Down Expand Up @@ -468,7 +471,7 @@ public static TIFJobState toState(String stateName) {
return TIFJobState.valueOf(stateName);
} catch (IllegalArgumentException e) {
log.error("Invalid state, cannot be parsed.", e);
throw SecurityAnalyticsException.wrap(e);
throw SecurityAnalyticsException.wrap(new OpenSearchStatusException("Invalid state, cannot be parsed.", RestStatus.BAD_REQUEST));
}
}

Expand All @@ -477,7 +480,7 @@ public static SourceConfigType toSourceConfigType(String type) {
return SourceConfigType.valueOf(type);
} catch (IllegalArgumentException e) {
log.error("Invalid source config type, cannot be parsed.", e);
throw SecurityAnalyticsException.wrap(e);
throw SecurityAnalyticsException.wrap(new OpenSearchStatusException("Invalid source config type, cannot be parsed.", RestStatus.BAD_REQUEST));
}
}

Expand All @@ -486,7 +489,7 @@ public static RefreshType toRefreshType(String stateName) {
return RefreshType.valueOf(stateName);
} catch (IllegalArgumentException e) {
log.error("Invalid refresh type, cannot be parsed.", e);
throw SecurityAnalyticsException.wrap(e);
throw SecurityAnalyticsException.wrap(new OpenSearchStatusException("Invalid refresh type, cannot be parsed.", RestStatus.BAD_REQUEST));
}
}

Expand Down

0 comments on commit c3f386e

Please sign in to comment.