-
-
Notifications
You must be signed in to change notification settings - Fork 33k
lib: improve error handling in Buffer.concat #59592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
18b7d69
to
553175d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #59592 +/- ##
==========================================
+ Coverage 89.82% 89.85% +0.02%
==========================================
Files 666 667 +1
Lines 195337 196145 +808
Branches 38345 38512 +167
==========================================
+ Hits 175463 176246 +783
- Misses 12329 12364 +35
+ Partials 7545 7535 -10
🚀 New features to boost your workflow:
|
throw new ERR_INVALID_ARG_TYPE( | ||
`list[${i}]`, ['Buffer', 'Uint8Array'], list[i]); | ||
throw new ERR_INVALID_ARRAY_ELEMENT_TYPE( | ||
'list', i, ['Buffer', 'Uint8Array'], list[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could imagine this error to be useful for other container types too (e.g. sets)... maybe the name shouldn't be specific to array? ERR_INVALID_CONTAINER_ELEMENT_TYPE
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated to more general error type ERR_INVALID_CONTAINER_ELEMENT_TYPE
.
Thank you for comment.
/cc @BridgeAR since it's your todo comment being addressed here :-) |
- Replace ERR_INVALID_ARG_TYPE with ERR_INVALID_CONTAINER_ELEMENT_TYPE for clarity in error messages - Update test-buffer-concat.js with new error code and message format - Add new error ERR_INVALID_CONTAINER_ELEMENT_TYPE in lib/internal/errors.js - Add document for ERR_INVALID_CONTAINER_ELEMENT_TYPE in doc/api/errors.md
553175d
to
2811ce1
Compare
Improve error handling in
Buffer.concat
. I replaced the genericERR_INVALID_ARG_TYPE
with the more specificERR_INVALID_CONTAINER_ELEMENT_TYPE
to provide a clearer error message. To make this change, I updated the test code intest-buffer-concat.js
to check for the new error code and message format. And also added theERR_INVALID_CONTAINER_ELEMENT_TYPE
error type tolib/internal/errors.js
and included documentation for it indoc/api/errors.md
. This error type can be used for checking elements in continaers.I think this is samver-major PR.