类:RangeError


【Class: RangeError

表示提供的参数不在函数可接受值的集合或范围内;无论是数值范围,还是超出了给定函数参数的选项集合。

【Indicates that a provided argument was not within the set or range of acceptable values for a function; whether that is a numeric range, or outside the set of options for a given function parameter.】

require('node:net').connect(-1);
// Throws "RangeError: "port" option should be >= 0 and < 65536: -1" 

Node.js 会立即生成并抛出 RangeError 实例,作为一种参数验证形式。

【Node.js will generate and throw RangeError instances immediately as a form of argument validation.】