Skip to content

Commit

Permalink
switch to @octokit/request-error
Browse files Browse the repository at this point in the history
  • Loading branch information
frangio committed Nov 3, 2019
1 parent 26876dd commit f4d7618
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"homepage": "https://github.com/octokit/auth-app.js#readme",
"dependencies": {
"@octokit/request": "^5.3.0",
"@octokit/request-error": "^1.0.4",
"@octokit/types": "^1.1.0",
"@types/lru-cache": "^5.1.0",
"lru-cache": "^5.1.1",
Expand Down
8 changes: 5 additions & 3 deletions src/get-oauth-authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
StrategyOptionsWithDefaults,
OAuthAccesTokenAuthentication
} from "./types";
import { RequestError } from '@octokit/request-error';

export async function getOAuthAuthentication(
state: StrategyOptionsWithDefaults,
Expand Down Expand Up @@ -37,9 +38,10 @@ export async function getOAuthAuthentication(
const response = await request(route, parameters);

if (response.data.error !== undefined) {
throw new Error(
response.data.error_description || `Unknown error: ${response.data.error}`
);
throw new RequestError(`${response.data.error_description} (${response.data.error})`, response.status, {
headers: response.headers,
request: request.endpoint(route, parameters)
});
}

const {
Expand Down

0 comments on commit f4d7618

Please sign in to comment.