Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 3a6b048

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge 29423b4 as of 2017-11-25 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
2 parents 4316cb7 + 29423b4 commit 3a6b048

15 files changed

+318
-284
lines changed

doc/api/url.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ changes:
971971
The `url.format()` method returns a formatted URL string derived from
972972
`urlObject`.
973973

974-
If `urlObject` is not an object or a string, `url.parse()` will throw a
974+
If `urlObject` is not an object or a string, `url.format()` will throw a
975975
[`TypeError`][].
976976

977977
The formatting process operates as follows:

doc/onboarding-extras.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
| `bootstrap_node.js` | @fishrock123 |
99
| `doc/*`, `*.md` | @nodejs/documentation |
1010
| `lib/assert` | @nodejs/testing |
11+
| `lib/async_hooks` | @nodejs/async\_hooks for bugs/reviews (+ @nodejs/diagnostics for API) |
1112
| `lib/buffer` | @nodejs/buffer |
1213
| `lib/child_process` | @bnoordhuis, @cjihrig |
1314
| `lib/cluster` | @bnoordhuis, @cjihrig, @mcollina |
@@ -29,8 +30,8 @@
2930
| `src/node_crypto.*` | @nodejs/crypto |
3031
| `test/*` | @nodejs/testing |
3132
| `tools/eslint`, `.eslintrc` | @not-an-aardvark, @silverwind, @trott |
32-
| async\_hooks | @nodejs/async\_hooks for bugs/reviews (+ @nodejs/diagnostics for API) |
3333
| build | @nodejs/build |
34+
| ES Modules | @bmeck, @Fishrock123, @guybedford, @MylesBorins, @targos |
3435
| GYP | @nodejs/gyp |
3536
| performance | @nodejs/performance |
3637
| platform specific | @nodejs/platform-{aix,arm,freebsd,macos,ppc,smartos,s390,windows} |

lib/fs.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ fs.access = function(path, mode, callback) {
297297
if (handleError((path = getPathFromURL(path)), callback))
298298
return;
299299

300+
if (typeof path !== 'string' && !(path instanceof Buffer)) {
301+
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'path',
302+
['string', 'Buffer', 'URL']);
303+
}
304+
300305
if (!nullCheck(path, callback))
301306
return;
302307

@@ -308,14 +313,25 @@ fs.access = function(path, mode, callback) {
308313

309314
fs.accessSync = function(path, mode) {
310315
handleError((path = getPathFromURL(path)));
316+
317+
if (typeof path !== 'string' && !(path instanceof Buffer)) {
318+
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'path',
319+
['string', 'Buffer', 'URL']);
320+
}
321+
311322
nullCheck(path);
312323

313324
if (mode === undefined)
314325
mode = fs.F_OK;
315326
else
316327
mode = mode | 0;
317328

318-
binding.access(pathModule.toNamespacedPath(path), mode);
329+
const ctx = {};
330+
binding.access(pathModule.toNamespacedPath(path), mode, undefined, ctx);
331+
332+
if (ctx.code !== undefined) {
333+
throw new errors.uvException(ctx);
334+
}
319335
};
320336

321337
fs.exists = function(path, callback) {

lib/internal/errors.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,49 @@ function E(sym, val) {
194194
messages.set(sym, typeof val === 'function' ? val : String(val));
195195
}
196196

197+
// JS counterpart of StringFromPath, although here path is a buffer.
198+
function stringFromPath(path) {
199+
const str = path.toString();
200+
if (process.platform !== 'win32') {
201+
return str;
202+
}
203+
204+
if (str.startsWith('\\\\?\\UNC\\')) {
205+
return '\\\\' + str.slice(8);
206+
} else if (str.startsWith('\\\\?\\')) {
207+
return str.slice(4);
208+
}
209+
return str;
210+
}
211+
212+
// This creates an error compatible with errors produced in UVException
213+
// using the context collected in CollectUVExceptionInfo
214+
// The goal is to migrate them to ERR_* errors later when
215+
// compatibility is not a concern
216+
function uvException(ctx) {
217+
const err = new Error();
218+
err.errno = ctx.errno;
219+
err.code = ctx.code;
220+
err.syscall = ctx.syscall;
221+
222+
let message = `${ctx.code}: ${ctx.message}, ${ctx.syscall}`;
223+
if (ctx.path) {
224+
const path = stringFromPath(ctx.path);
225+
message += ` '${path}'`;
226+
err.path = path;
227+
}
228+
if (ctx.dest) {
229+
const dest = stringFromPath(ctx.dest);
230+
message += ` -> '${dest}'`;
231+
err.dest = dest;
232+
}
233+
err.message = message;
234+
Error.captureStackTrace(err, uvException);
235+
return err;
236+
}
237+
197238
module.exports = exports = {
239+
uvException,
198240
message,
199241
Error: makeNodeError(Error),
200242
TypeError: makeNodeError(TypeError),

0 commit comments

Comments
 (0)