test: fix wrong error classes passed in as type
PR-URL: https://github.com/nodejs/node/pull/13686 Fixes: https://github.com/nodejs/node/issues/13682 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
22760f31be
commit
f26cabbe24
@ -36,7 +36,7 @@ common.expectsError(
|
|||||||
}, ''),
|
}, ''),
|
||||||
{
|
{
|
||||||
code: 'ERR_INVALID_OPT_VALUE',
|
code: 'ERR_INVALID_OPT_VALUE',
|
||||||
type: Error,
|
type: TypeError,
|
||||||
message: 'The value "undefined" is invalid for option "padding"'
|
message: 'The value "undefined" is invalid for option "padding"'
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ common.expectsError(
|
|||||||
}, ''),
|
}, ''),
|
||||||
{
|
{
|
||||||
code: 'ERR_INVALID_OPT_VALUE',
|
code: 'ERR_INVALID_OPT_VALUE',
|
||||||
type: Error,
|
type: TypeError,
|
||||||
message: 'The value "undefined" is invalid for option "saltLength"'
|
message: 'The value "undefined" is invalid for option "saltLength"'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ const assert = require('assert');
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: Error
|
type: TypeError
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ common.expectsError(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: Error
|
type: TypeError
|
||||||
});
|
});
|
||||||
|
|
||||||
const okInputs = [1, -1, '1', '-1', Date.now()];
|
const okInputs = [1, -1, '1', '-1', Date.now()];
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Flags: --expose-internals
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
@ -6,6 +7,7 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const http2 = require('http2');
|
const http2 = require('http2');
|
||||||
|
const { NghttpError } = require('internal/http2/util');
|
||||||
|
|
||||||
// Creating an http1 server here...
|
// Creating an http1 server here...
|
||||||
const server = http.createServer(common.mustNotCall());
|
const server = http.createServer(common.mustNotCall());
|
||||||
@ -18,13 +20,14 @@ server.listen(0, common.mustCall(() => {
|
|||||||
|
|
||||||
req.on('error', common.expectsError({
|
req.on('error', common.expectsError({
|
||||||
code: 'ERR_HTTP2_ERROR',
|
code: 'ERR_HTTP2_ERROR',
|
||||||
type: Error,
|
type: NghttpError,
|
||||||
message: 'Protocol error'
|
message: 'Protocol error'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
client.on('error', common.expectsError({
|
client.on('error', common.expectsError({
|
||||||
code: 'ERR_HTTP2_ERROR',
|
code: 'ERR_HTTP2_ERROR',
|
||||||
type: Error,
|
type: NghttpError,
|
||||||
|
name: 'Error [ERR_HTTP2_ERROR]',
|
||||||
message: 'Protocol error'
|
message: 'Protocol error'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Flags: --expose-internals
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
@ -10,6 +11,7 @@ const {
|
|||||||
nghttp2ErrorString
|
nghttp2ErrorString
|
||||||
} = process.binding('http2');
|
} = process.binding('http2');
|
||||||
const http2 = require('http2');
|
const http2 = require('http2');
|
||||||
|
const { NghttpError } = require('internal/http2/util');
|
||||||
|
|
||||||
// tests error handling within requestOnConnect
|
// tests error handling within requestOnConnect
|
||||||
// - NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE (should emit session error)
|
// - NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE (should emit session error)
|
||||||
@ -51,7 +53,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
|
|||||||
ngError: constants[key],
|
ngError: constants[key],
|
||||||
error: {
|
error: {
|
||||||
code: 'ERR_HTTP2_ERROR',
|
code: 'ERR_HTTP2_ERROR',
|
||||||
type: Error,
|
type: NghttpError,
|
||||||
|
name: 'Error [ERR_HTTP2_ERROR]',
|
||||||
message: nghttp2ErrorString(constants[key])
|
message: nghttp2ErrorString(constants[key])
|
||||||
},
|
},
|
||||||
type: 'session'
|
type: 'session'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Flags: --expose-internals
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
@ -9,6 +10,7 @@ const {
|
|||||||
Http2Stream,
|
Http2Stream,
|
||||||
nghttp2ErrorString
|
nghttp2ErrorString
|
||||||
} = process.binding('http2');
|
} = process.binding('http2');
|
||||||
|
const { NghttpError } = require('internal/http2/util');
|
||||||
|
|
||||||
// tests error handling within additionalHeaders
|
// tests error handling within additionalHeaders
|
||||||
// - every other NGHTTP2 error from binding (should emit stream error)
|
// - every other NGHTTP2 error from binding (should emit stream error)
|
||||||
@ -24,7 +26,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
|
|||||||
ngError: constants[key],
|
ngError: constants[key],
|
||||||
error: {
|
error: {
|
||||||
code: 'ERR_HTTP2_ERROR',
|
code: 'ERR_HTTP2_ERROR',
|
||||||
type: Error,
|
type: NghttpError,
|
||||||
|
name: 'Error [ERR_HTTP2_ERROR]',
|
||||||
message: nghttp2ErrorString(constants[key])
|
message: nghttp2ErrorString(constants[key])
|
||||||
},
|
},
|
||||||
type: 'stream'
|
type: 'stream'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Flags: --expose-internals
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
@ -7,6 +8,7 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const h2 = require('http2');
|
const h2 = require('http2');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
const { NghttpError } = require('internal/http2/util');
|
||||||
const h2test = require('../common/http2');
|
const h2test = require('../common/http2');
|
||||||
let client;
|
let client;
|
||||||
|
|
||||||
@ -18,7 +20,7 @@ server.on('stream', common.mustCall((stream) => {
|
|||||||
server.on('session', common.mustCall((session) => {
|
server.on('session', common.mustCall((session) => {
|
||||||
session.on('error', common.expectsError({
|
session.on('error', common.expectsError({
|
||||||
code: 'ERR_HTTP2_ERROR',
|
code: 'ERR_HTTP2_ERROR',
|
||||||
type: Error,
|
type: NghttpError,
|
||||||
message: 'Stream was already closed or invalid'
|
message: 'Stream was already closed or invalid'
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Flags: --expose-internals
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
@ -9,6 +10,7 @@ const {
|
|||||||
Http2Stream,
|
Http2Stream,
|
||||||
nghttp2ErrorString
|
nghttp2ErrorString
|
||||||
} = process.binding('http2');
|
} = process.binding('http2');
|
||||||
|
const { NghttpError } = require('internal/http2/util');
|
||||||
|
|
||||||
// tests error handling within respond
|
// tests error handling within respond
|
||||||
// - every other NGHTTP2 error from binding (should emit stream error)
|
// - every other NGHTTP2 error from binding (should emit stream error)
|
||||||
@ -25,7 +27,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
|
|||||||
ngError: constants[key],
|
ngError: constants[key],
|
||||||
error: {
|
error: {
|
||||||
code: 'ERR_HTTP2_ERROR',
|
code: 'ERR_HTTP2_ERROR',
|
||||||
type: Error,
|
type: NghttpError,
|
||||||
|
name: 'Error [ERR_HTTP2_ERROR]',
|
||||||
message: nghttp2ErrorString(constants[key])
|
message: nghttp2ErrorString(constants[key])
|
||||||
},
|
},
|
||||||
type: 'stream'
|
type: 'stream'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Flags: --expose-internals
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ const {
|
|||||||
Http2Stream,
|
Http2Stream,
|
||||||
nghttp2ErrorString
|
nghttp2ErrorString
|
||||||
} = process.binding('http2');
|
} = process.binding('http2');
|
||||||
|
const { NghttpError } = require('internal/http2/util');
|
||||||
|
|
||||||
// tests error handling within processRespondWithFD
|
// tests error handling within processRespondWithFD
|
||||||
// (called by respondWithFD & respondWithFile)
|
// (called by respondWithFD & respondWithFile)
|
||||||
@ -32,7 +34,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
|
|||||||
ngError: constants[key],
|
ngError: constants[key],
|
||||||
error: {
|
error: {
|
||||||
code: 'ERR_HTTP2_ERROR',
|
code: 'ERR_HTTP2_ERROR',
|
||||||
type: Error,
|
type: NghttpError,
|
||||||
|
name: 'Error [ERR_HTTP2_ERROR]',
|
||||||
message: nghttp2ErrorString(constants[key])
|
message: nghttp2ErrorString(constants[key])
|
||||||
},
|
},
|
||||||
type: 'stream'
|
type: 'stream'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Flags: --expose-internals
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
@ -7,6 +8,7 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const http2 = require('http2');
|
const http2 = require('http2');
|
||||||
|
const { NghttpError } = require('internal/http2/util');
|
||||||
|
|
||||||
const server = http2.createServer();
|
const server = http2.createServer();
|
||||||
server.on('stream', common.mustNotCall());
|
server.on('stream', common.mustNotCall());
|
||||||
@ -14,7 +16,7 @@ server.on('session', common.mustCall((session) => {
|
|||||||
session.on('close', common.mustCall());
|
session.on('close', common.mustCall());
|
||||||
session.on('error', common.expectsError({
|
session.on('error', common.expectsError({
|
||||||
code: 'ERR_HTTP2_ERROR',
|
code: 'ERR_HTTP2_ERROR',
|
||||||
type: Error,
|
type: NghttpError,
|
||||||
message: 'Received bad client magic byte string'
|
message: 'Received bad client magic byte string'
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Flags: --expose-internals
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
@ -9,6 +10,7 @@ const {
|
|||||||
Http2Stream,
|
Http2Stream,
|
||||||
nghttp2ErrorString
|
nghttp2ErrorString
|
||||||
} = process.binding('http2');
|
} = process.binding('http2');
|
||||||
|
const { NghttpError } = require('internal/http2/util');
|
||||||
|
|
||||||
// tests error handling within pushStream
|
// tests error handling within pushStream
|
||||||
// - NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE (should emit session error)
|
// - NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE (should emit session error)
|
||||||
@ -49,7 +51,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
|
|||||||
ngError: constants[key],
|
ngError: constants[key],
|
||||||
error: {
|
error: {
|
||||||
code: 'ERR_HTTP2_ERROR',
|
code: 'ERR_HTTP2_ERROR',
|
||||||
type: Error,
|
type: NghttpError,
|
||||||
|
name: 'Error [ERR_HTTP2_ERROR]',
|
||||||
message: nghttp2ErrorString(constants[key])
|
message: nghttp2ErrorString(constants[key])
|
||||||
},
|
},
|
||||||
type: 'stream'
|
type: 'stream'
|
||||||
|
@ -163,7 +163,11 @@ assert.doesNotThrow(() => {
|
|||||||
assert.doesNotThrow(() => {
|
assert.doesNotThrow(() => {
|
||||||
common.expectsError(() => {
|
common.expectsError(() => {
|
||||||
throw new errors.TypeError('TEST_ERROR_1', 'a');
|
throw new errors.TypeError('TEST_ERROR_1', 'a');
|
||||||
}, { code: 'TEST_ERROR_1', type: Error });
|
}, {
|
||||||
|
code: 'TEST_ERROR_1',
|
||||||
|
type: TypeError,
|
||||||
|
message: 'Error for testing purposes: a'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
common.expectsError(() => {
|
common.expectsError(() => {
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Flags: --expose-internals
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const tty = require('tty');
|
const tty = require('tty');
|
||||||
|
const { SystemError } = require('internal/errors');
|
||||||
|
|
||||||
common.expectsError(
|
common.expectsError(
|
||||||
() => new tty.WriteStream(-1),
|
() => new tty.WriteStream(-1),
|
||||||
@ -27,7 +30,7 @@ common.expectsError(
|
|||||||
new tty.WriteStream(fd);
|
new tty.WriteStream(fd);
|
||||||
}, {
|
}, {
|
||||||
code: 'ERR_SYSTEM_ERROR',
|
code: 'ERR_SYSTEM_ERROR',
|
||||||
type: Error,
|
type: SystemError,
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -42,7 +45,7 @@ common.expectsError(
|
|||||||
new tty.ReadStream(fd);
|
new tty.ReadStream(fd);
|
||||||
}, {
|
}, {
|
||||||
code: 'ERR_SYSTEM_ERROR',
|
code: 'ERR_SYSTEM_ERROR',
|
||||||
type: Error,
|
type: SystemError,
|
||||||
message
|
message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user