mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
errors: improve ERR_INVALID_ARG_TYPE
ERR_INVALID_ARG_TYPE is the most common error used throughout the code base. This improves the error message by providing more details to the user and by indicating more precisely which values are allowed ones and which ones are not. It adds the actual input to the error message in case it's a primitive. If it's a class instance, it'll print the class name instead of "object" and "falsy" or similar entries are not named "type" anymore. PR-URL: https://github.com/nodejs/node/pull/29675 Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
ae3459af9f
commit
df94cfb67c
127 files changed
+666
-538
No files matched your search
@@ -43,8 +43,9 @@ assert.throws(function() {
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
name: 'TypeError',
|
||||
message: 'The first argument must be one of type string, Buffer,' +
|
||||
' ArrayBuffer, Array, or Array-like Object. Received type object'
|
||||
message: 'The first argument must be of type string or an instance of ' +
|
||||
'Buffer, ArrayBuffer, or Array or an Array-like Object. Received ' +
|
||||
'an instance of AB'
|
||||
});
|
||||
|
||||
// Test the byteOffset and length arguments
|
||||
|
||||
Reference in new issue
Block a user