File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed
libs/core/src/main/java/org/opensearch Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -105,18 +105,14 @@ public static RestStatus status(Throwable t) {
105
105
}
106
106
107
107
public static String summaryMessage (Throwable t ) {
108
- if (t != null ) {
109
- if (t instanceof OpenSearchException ) {
110
- return getExceptionSimpleClassName (t ) + "[" + t .getMessage () + "]" ;
111
- } else if (t instanceof IllegalArgumentException ) {
112
- return "Invalid argument" ;
113
- } else if (t instanceof JsonParseException ) {
114
- return "Failed to parse JSON" ;
115
- } else if (t instanceof OpenSearchRejectedExecutionException ) {
116
- return "Too many requests" ;
117
- }
118
- }
119
- return "Internal failure" ;
108
+ return switch (t ) {
109
+ case OpenSearchException ose -> getExceptionSimpleClassName (t ) + "[" + t .getMessage () + "]" ;
110
+ case IllegalArgumentException iae -> "Invalid argument" ;
111
+ case JsonParseException jpe -> "Failed to parse JSON" ;
112
+ case OpenSearchRejectedExecutionException osre -> "Too many requests" ;
113
+ case null -> "Internal failure" ;
114
+ default -> "Internal failure" ;
115
+ };
120
116
}
121
117
122
118
public static Throwable unwrapCause (Throwable t ) {
You can’t perform that action at this time.
0 commit comments