Sha256: 82636e7d7d598a040c23551787996e7ed7d6529a07f03c5083278a85b449233a

Contents?: true

Size: 841 Bytes

Versions: 26

Compression:

Stored size: 841 Bytes

Contents

'use strict';
// Older verions of Node.js might not have `util.getSystemErrorName()`.
// In that case, fall back to a deprecated internal.
const util = require('util');

let uv;

if (typeof util.getSystemErrorName === 'function') {
	module.exports = util.getSystemErrorName;
} else {
	try {
		uv = process.binding('uv');

		if (typeof uv.errname !== 'function') {
			throw new TypeError('uv.errname is not a function');
		}
	} catch (err) {
		console.error('execa/lib/errname: unable to establish process.binding(\'uv\')', err);
		uv = null;
	}

	module.exports = code => errname(uv, code);
}

// Used for testing the fallback behavior
module.exports.__test__ = errname;

function errname(uv, code) {
	if (uv) {
		return uv.errname(code);
	}

	if (!(code < 0)) {
		throw new Error('err >= 0');
	}

	return `Unknown system error ${code}`;
}

Version data entries

26 entries across 25 versions & 8 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/execa/lib/errname.js
disco_app-0.18.0 test/dummy/node_modules/execa/lib/errname.js
disco_app-0.18.2 test/dummy/node_modules/execa/lib/errname.js
disco_app-0.16.1 test/dummy/node_modules/execa/lib/errname.js
disco_app-0.15.2 test/dummy/node_modules/execa/lib/errname.js
disco_app-0.18.4 test/dummy/node_modules/execa/lib/errname.js
disco_app-0.18.1 test/dummy/node_modules/execa/lib/errname.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/execa/lib/errname.js
disco_app-0.14.0 test/dummy/node_modules/execa/lib/errname.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/execa/lib/errname.js
tang-0.2.1 spec/tang_app/node_modules/execa/lib/errname.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/execa/lib/errname.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/execa/lib/errname.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/execa/lib/errname.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/execa/lib/errname.js
tang-0.2.0 spec/tang_app/node_modules/execa/lib/errname.js
tang-0.1.0 spec/tang_app/node_modules/execa/lib/errname.js
tang-0.0.9 spec/tang_app/node_modules/execa/lib/errname.js
enju_library-0.3.8 spec/dummy/node_modules/execa/lib/errname.js
jester-data-8.0.0 node_modules/execa/lib/errname.js