Skip to content

Commit

Permalink
Add error handling to login command (#974)
Browse files Browse the repository at this point in the history
* add error handling on login command

* fix error message
  • Loading branch information
nkzawa authored and leo committed Nov 13, 2017
1 parent b86368a commit 7f86e54
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/providers/sh/commands/login.js
Expand Up @@ -110,6 +110,15 @@ const getVerificationData = async ({ apiUrl, email }) => {
)
}

if (!res.ok) {
debug('error response from POST /now/registration: %d %j', res.status, body)
const { error = {} } = body
const message = error.code === 'invalid_email'
? 'Invalid email address'
: `Unexpected error: ${error.message}`
throw new Error(message)
}

return body
}

Expand Down

0 comments on commit 7f86e54

Please sign in to comment.