Skip to content

Commit

Permalink
improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Jan 25, 2024
1 parent 5d5d7bc commit e8b47b5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/pds/src/twilio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@ export class TwilioClient {
})
} catch (err) {
log.error({ err, phoneNumber }, 'error sending twilio code')
throw new UpstreamFailureError('Could not send verification text')
const code = typeof err === 'object' ? err?.['code'] : undefined
if (code === 60200) {
throw new InvalidRequestError(
'Could not send verification text: invalid phone number',
)
} else if (code === 60220) {
throw new InvalidRequestError(
`We're sorry, we're not currently able to send verification messages to China. We're working with our providers to solve this as quickly as possible.`,
)
} else {
throw new UpstreamFailureError('Could not send verification text')
}
}
}

Expand Down

0 comments on commit e8b47b5

Please sign in to comment.