openBackhaul / RegistryOffice

Apache License 2.0
2 stars 8 forks source link

response-code is set as INTERNAL_SERVER_ERROR in catch block for all services #422

Closed IswaryaaS closed 1 year ago

IswaryaaS commented 1 year ago

In Controller/[filename].js , there is a catch block that catches if there is any exception thrown in any internal flow of the services. In all services, the catch block is commonly made the response-code as "INTERNAL_SERVER_ERROR" which would give 500 response code irrespective of the error. The error may be because of wrong input or something not supported or internal-server-error.

}) .catch(async function (responseBody) { responseBodyToDocument = responseBody; responseCode = responseCodeEnum.code.INTERNAL_SERVER_ERROR; let responseHeader = await restResponseHeader.createResponseHeader(xCorrelator, startTime, req.url); restResponseBuilder.buildResponse(res, responseCode, responseBody, responseHeader); });

proposal: We need to analyze possible response codes for all services (both in AP and in all individual applications) and update the response block for error condition.

Priority:High

MartinSunal commented 1 year ago

Controller part is resolved in https://github.com/openBackhaul/RegistryOffice/pull/450 After it is merged then errors from http-errors lib can be thrown from service layer where needed.

PrathibaJee commented 1 year ago

While dealing this issue , please also take care of the updateApprovalStatus method in server/controllers/IndividualServices.js.(we are using the onf-core-model-ap/applicationPattern/rest/server/HttpException in this.)