Skip to content

Commit

Permalink
refactor(AuthController): update error type check to ApplicationError
Browse files Browse the repository at this point in the history
  • Loading branch information
karrui committed Sep 3, 2020
1 parent c8c0217 commit 9db99b4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/app/modules/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import defaults from '../../../config/defaults'
import { createLoggerWithLabel } from '../../../config/logger'
import MailService from '../../services/mail.service'
import { getRequestIp } from '../../utils/request'
import { ApplicationError } from '../core/core.errors'
import * as UserService from '../user/user.service'

import { InvalidOtpError } from './auth.errors'
import * as AuthService from './auth.service'

const logger = createLoggerWithLabel(module)
Expand Down Expand Up @@ -108,14 +108,14 @@ export const handleLoginVerifyOtp: RequestHandler<
if (verifyErr) {
logger.warn({
message:
verifyErr instanceof InvalidOtpError
verifyErr instanceof ApplicationError
? 'Login OTP is invalid'
: 'Error occurred when trying to validate login OTP',
meta: logMeta,
error: verifyErr,
})

if (verifyErr instanceof InvalidOtpError) {
if (verifyErr instanceof ApplicationError) {
return res.status(verifyErr.status).send(verifyErr.message)
}

Expand Down

0 comments on commit 9db99b4

Please sign in to comment.