diff --git a/src/createorUpdateIssue.ts b/src/createorUpdateIssue.ts index 0a1915a..1b27bc9 100644 --- a/src/createorUpdateIssue.ts +++ b/src/createorUpdateIssue.ts @@ -197,15 +197,31 @@ export async function createRepolinterIssue( } core.debug(`Creating issue "${options.issueName}"...`) // create the issue - const issue = await client.issues.create({ - owner: options.owner, - repo: options.repo, - title: options.issueName, - body: options.issueContent, - labels: [options.labelName], - assignees: - options.issueAssignee !== undefined ? [options.issueAssignee] : undefined - }) + let issue + try { + issue = await client.issues.create({ + owner: options.owner, + repo: options.repo, + title: options.issueName, + body: options.issueContent, + labels: [options.labelName], + assignees: + options.issueAssignee !== undefined + ? [options.issueAssignee] + : undefined + }) + } catch (e) { + if ((e as RequestError).status === 404) + throw new Error( + 'Creating an issue returned a 404! Did you setup a token with the correct permissions?' + ) + else if ((e as RequestError).status === 410) + throw new Error( + 'Creating an issue returned 410, are issues enabled on the repository?' + ) + else throw e + } + core.debug(`Successfully created issue #${issue.data.number}`) return issue.data } diff --git a/src/main.ts b/src/main.ts index 5810ed7..6a268c1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -117,5 +117,6 @@ export default async function run(disableRetry?: boolean): Promise { core.setFailed('A fatal error was thrown.') core.error(error as Error) if (error.stack) core.error(error.stack) + core.error(JSON.stringify(error)) } }