diff --git a/src/node_file.cc b/src/node_file.cc index cb974c2347..6e9ef1a4d6 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -568,7 +568,7 @@ static Handle Write(const Arguments& args) { ASYNC_CALL(write, cb, fd, buf, len, pos) } else { ssize_t written = pos < 0 ? write(fd, buf, len) : pwrite(fd, buf, len, pos); - if (written < 0) return ThrowException(ErrnoException(errno)); + if (written < 0) return ThrowException(ErrnoException(errno, "write")); return scope.Close(Integer::New(written)); } } diff --git a/test/simple/test-fs-write-buffer.js b/test/simple/test-fs-write-buffer.js index ca96b2312d..e97b2a3c34 100644 --- a/test/simple/test-fs-write-buffer.js +++ b/test/simple/test-fs-write-buffer.js @@ -1,14 +1,14 @@ require('../common'); -var path = require('path') - , Buffer = require('buffer').Buffer - , fs = require('fs') - , fn = path.join(fixturesDir, 'write.txt') - , expected = new Buffer('hello') - , openCalled = 0 - , writeCalled = 0; +var path = require('path'), + Buffer = require('buffer').Buffer, + fs = require('fs'), + filename = path.join(fixturesDir, 'write.txt'), + expected = new Buffer('hello'), + openCalled = 0, + writeCalled = 0; -fs.open(fn, 'w', 0644, function (err, fd) { +fs.open(filename, 'w', 0644, function (err, fd) { openCalled++; if (err) throw err; @@ -19,14 +19,14 @@ fs.open(fn, 'w', 0644, function (err, fd) { assert.equal(expected.length, written); fs.closeSync(fd); - var found = fs.readFileSync(fn); - assert.deepEqual(found, expected.toString()); - fs.unlinkSync(fn); + var found = fs.readFileSync(filename); + assert.deepEqual(expected.toString(), found); + fs.unlinkSync(filename); }); }); process.addListener("exit", function () { - assert.equal(openCalled, 1); - assert.equal(writeCalled, 1); + assert.equal(1, openCalled); + assert.equal(1, writeCalled); });