-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: #29288 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
- Loading branch information
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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.syscall, 'listen'); | ||
assert.strictEqual(exception.address, '127.0.0.1'); | ||
assert.strictEqual(exception.port, 80); | ||
} |