Skip to content

Commit

Permalink
Set response http code to 500 when internal error
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejkang committed Aug 22, 2021
1 parent 9605487 commit ed49772
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export class DriverLicenseVerificationController {
@ApiOperation({ summary: 'Verify License Information' })
@ApiResponse({ status: 200, description: 'Response Successfully', type: DriverLicenseVerificationControllerSuccessfulResponse })
@ApiResponse({ status: 400, description: 'Bad Request or Failed', type: DriverLicenseVerificationControllerFailedResponse })
@ApiResponse({ status: 403, description: 'Forbidden' })
@ApiResponse({ status: 500, description: 'Internal Server Error' })
@ApiResponse({ status: 500, description: 'Internal Server Error', type: DriverLicenseVerificationControllerFailedResponse })
async useCase(@Body() requestBody: DriverLicenseVerificationControllerRequestBody, @Res() response: Response) {
try {
const useCase = await this.createDriverLicenseVerificationUseCase.execute({ ...requestBody });
Expand All @@ -27,7 +26,8 @@ export class DriverLicenseVerificationController {
});
} catch (error) {
const errorMessage = error.name === 'InternalApiRequestError' ? 'Internal server error occured.' : error.message;
response.status(HttpStatus.BAD_REQUEST).json({
const responseHttpCode = error.name === 'InternalApiRequestError' ? HttpStatus.INTERNAL_SERVER_ERROR : HttpStatus.BAD_REQUEST;
response.status(responseHttpCode).json({
isSuccess: false,
errorCode: 0,
errorMessage: errorMessage,
Expand Down

0 comments on commit ed49772

Please sign in to comment.