Skip to content

Commit 4135f91

Browse files
authored
Merge pull request #12358 from ashera96/api-chat
Fix error flow error message propagate issue
2 parents 6984829 + 5f6c0ca commit 4135f91

File tree

2 files changed

+5
-4
lines changed
  • components/apimgt
    • org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils
    • org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl

2 files changed

+5
-4
lines changed

Diff for: components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -10440,10 +10440,10 @@ public static String invokeAIService(String endpointConfigName, String authToken
1044010440
if (statusCode == HttpStatus.SC_CREATED) {
1044110441
return responseStr;
1044210442
} else if (statusCode == HttpStatus.SC_UNAUTHORIZED) {
10443-
throw new APIManagementException("Unexpected response detected from the AI service." + responseStr,
10443+
throw new APIManagementException("Unexpected response detected from the AI service. " + responseStr,
1044410444
ExceptionCodes.AI_SERVICE_INVALID_ACCESS_TOKEN);
1044510445
} else {
10446-
throw new APIManagementException("Unexpected response detected from the AI service." + responseStr,
10446+
throw new APIManagementException("Unexpected response detected from the AI service. " + responseStr,
1044710447
ExceptionCodes.AI_SERVICE_INVALID_RESPONSE);
1044810448
}
1044910449
} catch (MalformedURLException e) {

Diff for: components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/ApisApiServiceImpl.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ public Response apiChatPost(String apiId, String apiChatAction, ApiChatRequestDT
293293
ApiChatResponseDTO.class);
294294
return Response.status(Response.Status.CREATED).entity(preparationResponseDTO).build();
295295
} catch (APIManagementException | IOException e) {
296-
String errorMessage = "Error encountered while executing the prepare statement of API Chat service";
296+
String errorMessage = "Error encountered while executing the prepare statement of API Chat " +
297+
"service. Cause: " + e.getCause().getMessage();
297298
RestApiUtil.handleInternalServerError(errorMessage, e, log);
298299
}
299300

@@ -360,7 +361,7 @@ public Response apiChatPost(String apiId, String apiChatAction, ApiChatRequestDT
360361
return Response.status(Response.Status.CREATED).entity(responseDTO).build();
361362
} catch (APIManagementException | IOException e) {
362363
String errorMessage = "Error encountered while executing the API Chat service to accommodate the " +
363-
"specified testing requirement";
364+
"specified testing requirement. Cause: " + e.getCause().getMessage();
364365
RestApiUtil.handleInternalServerError(errorMessage, e, log);
365366
}
366367
} else {

0 commit comments

Comments
 (0)