summaryrefslogtreecommitdiff
path: root/test/parallel/test-uv-unmapped-exception.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-08-23 16:43:17 -0400
committerRich Trott <rtrott@gmail.com>2019-08-27 11:27:33 -0700
commitc246f813f8b1bbc8f0e13ab77452da4dff437635 (patch)
tree7b0a2bca617cdfe86cfb2bce7389e2091addee0d /test/parallel/test-uv-unmapped-exception.js
parent5ba3a2c4b6dfb928a097b36523d59cd5fa70706b (diff)
downloadandroid-node-v8-c246f813f8b1bbc8f0e13ab77452da4dff437635.tar.gz
android-node-v8-c246f813f8b1bbc8f0e13ab77452da4dff437635.tar.bz2
android-node-v8-c246f813f8b1bbc8f0e13ab77452da4dff437635.zip
errors: provide defaults for unmapped uv errors
libuv does not map 100% of errors. When an unmapped error is encountered, the Map returns undefined, which is then unsuccessfully destructured, causing an exception. This commit adds a default value in the event of an unmapped error. PR-URL: https://github.com/nodejs/node/pull/29288 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/parallel/test-uv-unmapped-exception.js')
-rw-r--r--test/parallel/test-uv-unmapped-exception.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/parallel/test-uv-unmapped-exception.js b/test/parallel/test-uv-unmapped-exception.js
new file mode 100644
index 0000000000..0b63461dd2
--- /dev/null
+++ b/test/parallel/test-uv-unmapped-exception.js
@@ -0,0 +1,26 @@
+// Flags: --expose-internals
+'use strict';
+require('../common');
+const assert = require('assert');
+const { uvException, uvExceptionWithHostPort } = require('internal/errors');
+
+{
+ const exception = uvException({ errno: 100, syscall: 'open' });
+
+ assert.strictEqual(exception.message, 'UNKNOWN: unknown error, open');
+ assert.strictEqual(exception.errno, 100);
+ assert.strictEqual(exception.syscall, 'open');
+ assert.strictEqual(exception.code, 'UNKNOWN');
+}
+
+{
+ const exception = uvExceptionWithHostPort(100, 'listen', '127.0.0.1', 80);
+
+ assert.strictEqual(exception.message,
+ 'listen UNKNOWN: unknown error 127.0.0.1:80');
+ assert.strictEqual(exception.code, 'UNKNOWN');
+ assert.strictEqual(exception.errno, 100);
+ assert.strictEqual(exception.syscall, 'listen');
+ assert.strictEqual(exception.address, '127.0.0.1');
+ assert.strictEqual(exception.port, 80);
+}