interceptors: move throwOnError to interceptor#3331
Merged
ronag merged 28 commits intonodejs:mainfrom Jul 11, 2024
Merged
Conversation
mertcanaltin
commented
Jun 17, 2024
ronag
reviewed
Jun 17, 2024
Co-authored-by: Robert Nagy <ronagy@icloud.com>
ronag
reviewed
Jun 17, 2024
ronag
reviewed
Jun 17, 2024
Co-authored-by: Robert Nagy <ronagy@icloud.com>
ronag
reviewed
Jun 17, 2024
Co-authored-by: Robert Nagy <ronagy@icloud.com>
metcoder95
reviewed
Jun 18, 2024
Member
metcoder95
left a comment
There was a problem hiding this comment.
Please do not forget to add docs and TS types 👍
ronag
reviewed
Jun 20, 2024
ronag
reviewed
Jun 20, 2024
Member
ronag
left a comment
There was a problem hiding this comment.
Could we also apply it to one of the API decoreators?
e.g.
diff --git a/lib/api/api-request.js b/lib/api/api-request.js
index ced5590d..f91b830a 100644
--- a/lib/api/api-request.js
+++ b/lib/api/api-request.js
@@ -13,7 +13,7 @@ class RequestHandler extends AsyncResource {
throw new InvalidArgumentError('invalid opts')
}
- const { signal, method, opaque, body, onInfo, responseHeaders, throwOnError, highWaterMark } = opts
+ const { signal, method, opaque, body, onInfo, responseHeaders, highWaterMark } = opts
try {
if (typeof callback !== 'function') {
@@ -54,7 +54,6 @@ class RequestHandler extends AsyncResource {
this.trailers = {}
this.context = null
this.onInfo = onInfo || null
- this.throwOnError = throwOnError
this.highWaterMark = highWaterMark
this.signal = signal
this.reason = null
@@ -132,20 +131,14 @@ class RequestHandler extends AsyncResource {
this.callback = null
this.res = res
if (callback !== null) {
- if (this.throwOnError && statusCode >= 400) {
- this.runInAsyncScope(getResolveErrorBodyCallback, null,
- { callback, body: res, contentType, statusCode, statusMessage, headers }
- )
- } else {
- this.runInAsyncScope(callback, null, null, {
- statusCode,
- headers,
- trailers: this.trailers,
- opaque,
- body: res,
- context
- })
- }
+ this.runInAsyncScope(callback, null, null, {
+ statusCode,
+ headers,
+ trailers: this.trailers,
+ opaque,
+ body: res,
+ context
+ })
}
}
@@ -200,7 +193,7 @@ function request (opts, callback) {
}
try {
- this.dispatch(opts, new RequestHandler(opts, callback))
+ this.compose(responseErrorInterceptor()).dispatch(opts, new RequestHandler(opts, callback))
} catch (err) {
if (typeof callback !== 'function') {
throw err
ronag
reviewed
Jun 20, 2024
Co-authored-by: Robert Nagy <ronagy@icloud.com>
ronag
reviewed
Jun 20, 2024
ronag
reviewed
Jun 20, 2024
ronag
reviewed
Jun 20, 2024
added 2 commits
July 8, 2024 20:43
Member
Author
Solved 🚀 |
metcoder95
reviewed
Jul 9, 2024
Member
metcoder95
left a comment
There was a problem hiding this comment.
Let's add the respective TS types and docs 👍
Member
Author
Which md file should I put the doc in, do you have any suggestions? |
Member
Within |
metcoder95
reviewed
Jul 11, 2024
Member
metcoder95
left a comment
There was a problem hiding this comment.
Thanks! It LGTM, just smaller comments on the docs 👍
ronag
approved these changes
Jul 11, 2024
KhafraDev
requested changes
Jul 11, 2024
Co-authored-by: Khafra <maitken033380023@gmail.com>
KhafraDev
approved these changes
Jul 11, 2024
github-actions bot
pushed a commit
that referenced
this pull request
Sep 12, 2024
(cherry picked from commit 0ea1074)
Merged
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Issue:
Need assistance to resolve test failures.