Skip to content

Commit

Permalink
Merge pull request #270 from bobvanderlinden/pr-fix-raven-context
Browse files Browse the repository at this point in the history
Fix Raven incorrect contexts for error reports
  • Loading branch information
bobvanderlinden authored May 8, 2019
2 parents 88e43d9 + c277ba3 commit 5ff529f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/pull-request-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export function getPullRequestPlan (
}
default:
Raven.mergeContext({
extras: { pullRequestInfo }
extra: { pullRequestInfo }
})
throw new Error(`Merge state (${pullRequestInfo.mergeStateStatus}) was not recognized`)
}
Expand Down
11 changes: 5 additions & 6 deletions src/pull-request-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ export async function queryPullRequest (github: Context['github'], { owner, repo
'pullRequestNumber': pullRequestNumber
})

return Raven.context({
extras: { response }
}, () => {
const checkedResponse = validatePullRequestQuery(response)
return checkedResponse.repository.pullRequest
})
const checkedResponse = Raven.context({
extra: { response }
}, () => validatePullRequestQuery(response))

return checkedResponse.repository.pullRequest
}
15 changes: 10 additions & 5 deletions src/repository-worker.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Raven from 'raven'
import { WaitQueue } from './WaitQueue'
import { RepositoryReference, PullRequestReference } from './github-models'
import { handlePullRequest, PullRequestContext } from './pull-request-handler'
Expand Down Expand Up @@ -40,11 +41,15 @@ export class RepositoryWorker {
},
startedAt: new Date()
}
try {
await handlePullRequest(pullRequestContext, pullRequestReference)
} catch (err) {
this.onPullRequestError(pullRequestReference, err)
}
await Raven.context({
extra: { pullRequestReference }
}, async () => {
try {
await handlePullRequest(pullRequestContext, pullRequestReference)
} catch (err) {
this.onPullRequestError(pullRequestReference, err)
}
})
}

public queue (pullRequestNumber: number) {
Expand Down

0 comments on commit 5ff529f

Please sign in to comment.