openBackhaul / AdministratorAdministration

Administrates the list of administrators of the application layer.
Apache License 2.0
5 stars 8 forks source link

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

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/AdministratorAdministration/pull/247 After it is merged then errors from http-errors lib can be thrown from service layer where needed.