Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: destructure ERR_SYSTEM_ERROR properly #22394

Merged
merged 2 commits into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/os.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const constants = process.binding('constants').os;
const { deprecate } = require('internal/util');
const isWindows = process.platform === 'win32';

const { ERR_SYSTEM_ERROR } = require('internal/errors');
const { codes: { ERR_SYSTEM_ERROR } } = require('internal/errors');

const {
getCPUs,
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-os-checked-function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';
// Monkey patch the os binding before requiring any other modules, including
// common, which requires the os module.
process.binding('os').getHomeDirectory = function(ctx) {
ctx.syscall = 'foo';
ctx.code = 'bar';
ctx.message = 'baz';
};

const common = require('../common');
const os = require('os');

common.expectsError(os.homedir, {
message: /^A system error occurred: foo returned bar \(baz\)$/
});