child_process: add errno property to exceptions
In case of a write failure when using fork() an error would be thrown. The thrown exception was missing the `errno` property.
This commit is contained in:
parent
1695332941
commit
ca6ededbd1
@ -132,7 +132,7 @@ function setupChannel(target, channel) {
|
||||
var writeReq = channel.write(buffer, 0, buffer.length, sendHandle);
|
||||
|
||||
if (!writeReq) {
|
||||
throw new Error(errno + 'cannot write to IPC channel.');
|
||||
throw errnoException(errno, 'write', 'cannot write to IPC channel.');
|
||||
}
|
||||
|
||||
writeReq.oncomplete = nop;
|
||||
@ -471,11 +471,15 @@ ChildProcess.prototype.spawn = function(options) {
|
||||
};
|
||||
|
||||
|
||||
function errnoException(errorno, syscall) {
|
||||
function errnoException(errorno, syscall, errmsg) {
|
||||
// TODO make this more compatible with ErrnoException from src/node.cc
|
||||
// Once all of Node is using this function the ErrnoException from
|
||||
// src/node.cc should be removed.
|
||||
var e = new Error(syscall + ' ' + errorno);
|
||||
var message = syscall + ' ' + errorno;
|
||||
if (errmsg) {
|
||||
message += ' - ' + errmsg;
|
||||
}
|
||||
var e = new Error(message);
|
||||
e.errno = e.code = errorno;
|
||||
e.syscall = syscall;
|
||||
return e;
|
||||
|
Loading…
x
Reference in New Issue
Block a user