Skip to content

Commit

Permalink
catch github api error
Browse files Browse the repository at this point in the history
  • Loading branch information
Teamop committed Apr 26, 2018
1 parent b91e704 commit 86b69b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

## Master

* Catch the github api error thrown from @octokit/rest [@Teamop][]

# 3.6.0

* A Dangerfile can return a default export, and then Danger will handle the execution of that code [@orta][]
Expand Down
14 changes: 9 additions & 5 deletions source/platforms/github/GitHubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ const utils = (pr: GitHubPRDSL, api: GitHub): GitHubUtilsDSL => {
repo: repoSlug.split("/")[1],
owner: repoSlug.split("/")[0],
}
const response = await api.repos.getContent(opts)
if (response && response.data && response.data.type === "file") {
const buffer = new Buffer(response.data.content, response.data.encoding)
return buffer.toString()
} else {
try {
const response = await api.repos.getContent(opts)
if (response && response.data && response.data.type === "file") {
const buffer = new Buffer(response.data.content, response.data.encoding)
return buffer.toString()
} else {
return ""
}
} catch {
return ""
}
},
Expand Down

0 comments on commit 86b69b6

Please sign in to comment.