Skip to content

Commit

Permalink
fix: reject with real errors for GitLab API calls for better debugging
Browse files Browse the repository at this point in the history
In previous implementation, some GitLab API calls would make a Promise rejection with `undefined` as the reason.
And in the [global `unhandledRejection` handler](https://github.com/frantic1048/danger-js/blob/b67d710af4d177d57e7091a742da54a2e9fa37fc/source/commands/utils/sharedDangerfileArgs.ts#L5), it will print a generic "Error: undefined" message.
This makes debugging very hard.

This commit fixes the issue by filling in the rejection reason with the actual error.
  • Loading branch information
frantic1048 committed Sep 24, 2024
1 parent b67d710 commit b62df49
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions source/platforms/gitlab/GitLabAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,8 @@ class GitLabAPI {
return note as Types.MergeRequestNoteSchema
} catch (e) {
this.d("createMergeRequestNote", e)
throw e
}

return Promise.reject()
}

updateMergeRequestDiscussionNote = async (
Expand All @@ -207,9 +206,8 @@ class GitLabAPI {
return discussionNote as Types.MergeRequestDiscussionNoteSchema
} catch (e) {
this.d("updateMergeRequestDiscussionNote", e)
throw e
}

return Promise.reject()
}

updateMergeRequestNote = async (id: number, body: string): Promise<Types.MergeRequestNoteSchema> => {
Expand All @@ -220,9 +218,8 @@ class GitLabAPI {
return note as Types.MergeRequestNoteSchema
} catch (e) {
this.d("updateMergeRequestNote", e)
throw e
}

return Promise.reject()
}

// note: deleting the _only_ discussion note in a discussion also deletes the discussion \o/
Expand Down

0 comments on commit b62df49

Please sign in to comment.