Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] Handle unauthorized errors when user is not logged in #4975

Merged
merged 6 commits into from Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/now-cli/src/index.js
Expand Up @@ -640,6 +640,11 @@ const main = async argv_ => {
return 1;
}

if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
output.prettyError(err);
return 1;
}

if (err instanceof APIError && 400 <= err.status && err.status <= 499) {
err.message = err.serverMessage;
output.prettyError(err);
Expand Down
4 changes: 3 additions & 1 deletion packages/now-cli/src/util/errors-ts.ts
Expand Up @@ -68,7 +68,9 @@ export class InvalidToken extends NowError<'NOT_AUTHORIZED', {}> {
constructor() {
super({
code: `NOT_AUTHORIZED`,
message: `The specified token is not valid`,
message: `The specified token is not valid. Use ${getCommandName(
`login`
)} to generate a new token.`,
meta: {},
});
}
Expand Down