Skip to content

Commit

Permalink
fix: add some error reporting for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
prototypicalpro committed Sep 3, 2020
1 parent 997b530 commit b73c261
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/createorUpdateIssue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,6 @@ export default async function run(disableRetry?: boolean): Promise<void> {
core.setFailed('A fatal error was thrown.')
core.error(error as Error)
if (error.stack) core.error(error.stack)
core.error(JSON.stringify(error))
}
}

0 comments on commit b73c261

Please sign in to comment.