Version
17.2.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
$ touch example
$ node -e "require('fs').cp('example', 'example', console.log)"
This throws as expected ERR_FS_CP_EINVAL.
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned EINVAL (src and dest cannot be the same) example
^^^^^^
What do you see instead?
SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned undefined (src and dest cannot be the same) example
^^^^^^^^^
Additional information
I'm not sure if this is a bug or intentional behavior but seeing undefined in an error message was unexpected.
|
throw new ERR_FS_CP_EINVAL({ |
|
message: 'src and dest cannot be the same', |
|
path: dest, |
|
syscall: 'cp', |
|
errno: EINVAL, |
|
}); |
|
let message = `${prefix}: ${context.syscall} returned ` + |
|
`${context.code} (${context.message})`; |
Based on the code should new ERR_FS_CP_EINVAL pass code: EINVAL, or should SystemError use context.code ?? context.errno, or is this the intended behavior?
Version
17.2.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
This throws as expected ERR_FS_CP_EINVAL.
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
What do you see instead?
Additional information
I'm not sure if this is a bug or intentional behavior but seeing
undefinedin an error message was unexpected.node/lib/internal/fs/cp/cp.js
Lines 80 to 85 in 87d6fd7
node/lib/internal/errors.js
Lines 225 to 226 in c8a0404
Based on the code should new ERR_FS_CP_EINVAL pass
code: EINVAL, or should SystemError usecontext.code ?? context.errno, or is this the intended behavior?