Skip to content

Commit

Permalink
handle excpetion
Browse files Browse the repository at this point in the history
  • Loading branch information
zeshanziya committed Jun 5, 2024
1 parent 1feff70 commit b8aca03
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ export const getAccessToken = async (cliToken: string): Promise<string> => {
}

const data = await response.json()
return data

// Assuming the response data contains an access_token field
if (!data.access_token) {
throw new Error('No access token found in the response')
}

return data.access_token
} catch (error) {
if (error instanceof Error) {
throw new Error(`Unable to authenticate: ${error.message}`)
} else {
throw new Error(`Unable to authenticate: ${error}`)
throw new Error(`Unable to authenticate: ${String(error)}`)
}
}
}

0 comments on commit b8aca03

Please sign in to comment.