Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
child_process: add errno property to exceptions
Browse files Browse the repository at this point in the history
In case of a write failure when using fork() an error would be thrown. The
thrown exception was missing the `errno` property.
  • Loading branch information
AndreasMadsen authored and piscisaureus committed Jan 17, 2012
1 parent 1695332 commit ca6eded
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/child_process.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ca6eded

Please sign in to comment.