Skip to content

Commit

Permalink
fix: minor error clarity improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
prototypicalpro committed Sep 3, 2020
1 parent 2e60d13 commit 63d878b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
9 changes: 4 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function createRepolinterIssue(client, options) {
else if (e.status === 403)
throw new Error("Creating an issue returned status 403. This is probably due to a scope limitation of your PAT, check that you set the correct permissions (note that GITHUB_TOKEN cannot write repositories other than it's own)");
else if (e.status === 410)
throw new Error('Creating an issue returned status 410, are issues enabled on the repository?');
throw new Error('Creating an issue returned status 410, are issues enabled on the target repository?');
else
throw e;
}
Expand Down Expand Up @@ -554,11 +554,10 @@ function run(disableRetry) {
core.error(`${requestError.request.method} ${requestError.request.url} returned status ${requestError.status}`);
core.debug(JSON.stringify(error));
}
else {
else if (error.stack)
core.error(error.stack);
else
core.error(error);
if (error.stack)
core.error(error.stack);
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/createorUpdateIssue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,17 @@ export async function createRepolinterIssue(
: undefined
})
} catch (e) {
if ((e as RequestError).status === 404)
if (e.status === 404)
throw new Error(
'Creating an issue returned a 404! Is your token valid/does it have the correct permissions?'
)
else if (e.status === 403)
throw new Error(
"Creating an issue returned status 403. This is probably due to a scope limitation of your PAT, check that you set the correct permissions (note that GITHUB_TOKEN cannot write repositories other than it's own)"
)
else if ((e as RequestError).status === 410)
else if (e.status === 410)
throw new Error(
'Creating an issue returned status 410, are issues enabled on the repository?'
'Creating an issue returned status 410, are issues enabled on the target repository?'
)
else throw e
}
Expand Down
6 changes: 2 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ export default async function run(disableRetry?: boolean): Promise<void> {
`${requestError.request.method} ${requestError.request.url} returned status ${requestError.status}`
)
core.debug(JSON.stringify(error))
} else {
core.error(error as Error)
if (error.stack) core.error(error.stack)
}
} else if (error.stack) core.error(error.stack)
else core.error(error)
}
}

0 comments on commit 63d878b

Please sign in to comment.