Skip to content

Commit b62df49

Browse files
committed
fix: reject with real errors for GitLab API calls for better debugging
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.
1 parent b67d710 commit b62df49

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

source/platforms/gitlab/GitLabAPI.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,8 @@ class GitLabAPI {
184184
return note as Types.MergeRequestNoteSchema
185185
} catch (e) {
186186
this.d("createMergeRequestNote", e)
187+
throw e
187188
}
188-
189-
return Promise.reject()
190189
}
191190

192191
updateMergeRequestDiscussionNote = async (
@@ -207,9 +206,8 @@ class GitLabAPI {
207206
return discussionNote as Types.MergeRequestDiscussionNoteSchema
208207
} catch (e) {
209208
this.d("updateMergeRequestDiscussionNote", e)
209+
throw e
210210
}
211-
212-
return Promise.reject()
213211
}
214212

215213
updateMergeRequestNote = async (id: number, body: string): Promise<Types.MergeRequestNoteSchema> => {
@@ -220,9 +218,8 @@ class GitLabAPI {
220218
return note as Types.MergeRequestNoteSchema
221219
} catch (e) {
222220
this.d("updateMergeRequestNote", e)
221+
throw e
223222
}
224-
225-
return Promise.reject()
226223
}
227224

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

0 commit comments

Comments
 (0)