Skip to content

Commit

Permalink
[ENG-12118][eas-cli] improve error message if server returns `UNAUTHO…
Browse files Browse the repository at this point in the history
…RIZED_ERROR` (#2345)

* [eas-cli] improve error message if server returns `UNAUTHORIZED_ERROR`

* update CHANGELOG.md
  • Loading branch information
szdziedzic authored Apr 26, 2024
1 parent b3fca97 commit 1a65b2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This is the log of notable changes to EAS CLI and related packages.

### 🧹 Chores

- Improve error message if the server returns `UNAUTHORIZED_ERROR`. ([#2345](https://github.com/expo/eas-cli/pull/2345) by [@szdziedzic](https://github.com/szdziedzic))
- Fill in min expo-updates version for expo-updates CLI. ([#2344](https://github.com/expo/eas-cli/pull/2344) by [@wschurman](https://github.com/wschurman))

## [7.8.4](https://github.com/expo/eas-cli/releases/tag/v7.8.4) - 2024-04-24
Expand Down
9 changes: 8 additions & 1 deletion packages/eas-cli/src/commandUtils/EasCommand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Command } from '@oclif/core';
import { CombinedError } from '@urql/core';
import chalk from 'chalk';
import { GraphQLError } from 'graphql/error';
import nullthrows from 'nullthrows';

Expand Down Expand Up @@ -210,7 +211,13 @@ export default abstract class EasCommand extends Command {
const defaultMsg = `${messageLine}${requestIdLine}`;

if (graphQLError.extensions?.errorCode === 'UNAUTHORIZED_ERROR') {
return `You don't have the required permissions to perform this operation.\n\n${defaultMsg}`;
return `${chalk.bold(
`You don't have the required permissions to perform this operation.`
)}\n\nThis can sometimes happen if you are logged in as incorrect user.\nRun ${chalk.bold(
'eas whoami'
)} to check the username you are logged in as.\nRun ${chalk.bold(
'eas login'
)} to change the account.\n\nOriginal error message: ${defaultMsg}`;
}

return defaultMsg;
Expand Down

0 comments on commit 1a65b2c

Please sign in to comment.