source: trip-planner-front/node_modules/execa/lib/errname.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 841 bytes
RevLine 
[6a3a178]1'use strict';
2// Older verions of Node.js might not have `util.getSystemErrorName()`.
3// In that case, fall back to a deprecated internal.
4const util = require('util');
5
6let uv;
7
8if (typeof util.getSystemErrorName === 'function') {
9 module.exports = util.getSystemErrorName;
10} else {
11 try {
12 uv = process.binding('uv');
13
14 if (typeof uv.errname !== 'function') {
15 throw new TypeError('uv.errname is not a function');
16 }
17 } catch (err) {
18 console.error('execa/lib/errname: unable to establish process.binding(\'uv\')', err);
19 uv = null;
20 }
21
22 module.exports = code => errname(uv, code);
23}
24
25// Used for testing the fallback behavior
26module.exports.__test__ = errname;
27
28function errname(uv, code) {
29 if (uv) {
30 return uv.errname(code);
31 }
32
33 if (!(code < 0)) {
34 throw new Error('err >= 0');
35 }
36
37 return `Unknown system error ${code}`;
38}
39
Note: See TracBrowser for help on using the repository browser.