|
22 | 22 | import java.io.IOException;
|
23 | 23 | import java.util.Map;
|
24 | 24 |
|
| 25 | +import org.opensearch.OpenSearchParseException; |
25 | 26 | import org.opensearch.action.ActionRequest;
|
26 | 27 | import org.opensearch.action.ActionRequestValidationException;
|
27 | 28 | import org.opensearch.core.common.io.stream.StreamInput;
|
@@ -100,15 +101,20 @@ public static CreateConversationRequest fromRestRequest(RestRequest restRequest)
|
100 | 101 | if (!restRequest.hasContent()) {
|
101 | 102 | return new CreateConversationRequest();
|
102 | 103 | }
|
103 |
| - Map<String, String> body = restRequest.contentParser().mapStrings(); |
104 |
| - if (body.containsKey(ActionConstants.REQUEST_CONVERSATION_NAME_FIELD)) { |
105 |
| - return new CreateConversationRequest( |
106 |
| - body.get(ActionConstants.REQUEST_CONVERSATION_NAME_FIELD), |
107 |
| - body.get(APPLICATION_TYPE_FIELD) |
108 |
| - ); |
109 |
| - } else { |
110 |
| - return new CreateConversationRequest(); |
| 104 | + try { |
| 105 | + Map<String, String> body = restRequest.contentParser().mapStrings(); |
| 106 | + if (body.containsKey(ActionConstants.REQUEST_CONVERSATION_NAME_FIELD)) { |
| 107 | + return new CreateConversationRequest( |
| 108 | + body.get(ActionConstants.REQUEST_CONVERSATION_NAME_FIELD), |
| 109 | + body.get(APPLICATION_TYPE_FIELD) |
| 110 | + ); |
| 111 | + } else { |
| 112 | + return new CreateConversationRequest(); |
| 113 | + } |
| 114 | + } catch (IllegalStateException illegalStateException) { |
| 115 | + throw new OpenSearchParseException(illegalStateException.getMessage()); |
| 116 | + } catch (Exception exception) { |
| 117 | + throw new OpenSearchParseException(exception.getMessage()); |
111 | 118 | }
|
112 | 119 | }
|
113 |
| - |
114 | 120 | }
|
0 commit comments