| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1562fb9 commit dbfe8c4
28 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -575,6 +575,11 @@ Used as special type of error that can be triggered whenever Node.js detects an | |||
| 575 | 575 | exceptional logic violation that should never occur. These are raised typically | |
| 576 | 576 | by the `assert` module. | |
| 577 | 577 | ||
| 578 | + <a id="ERR_BUFFER_OUT_OF_BOUNDS"></a> | ||
| 579 | + ### ERR_BUFFER_OUT_OF_BOUNDS | ||
| 580 | + | ||
| 581 | + Used when attempting to perform an operation outside the bounds of a `Buffer`. | ||
| 582 | + | ||
| 578 | 583 | <a id="ERR_CONSOLE_WRITABLE_STREAM"></a> | |
| 579 | 584 | ### ERR_CONSOLE_WRITABLE_STREAM | |
| 580 | 585 | ||
@@ -625,6 +630,11 @@ to a Node.js API. | |||
| 625 | 630 | ||
| 626 | 631 | Used when an Array is not of the expected length or in a valid range. | |
| 627 | 632 | ||
| 633 | + <a id="ERR_INVALID_BUFFER_SIZE"></a> | ||
| 634 | + ### ERR_INVALID_BUFFER_SIZE | ||
| 635 | + | ||
| 636 | + Used when performing a swap on a `Buffer` but it's size is not compatible with the operation. | ||
| 637 | + | ||
| 628 | 638 | <a id="ERR_INVALID_CALLBACK"></a> | |
| 629 | 639 | ### ERR_INVALID_CALLBACK | |
| 630 | 640 | ||
@@ -781,6 +791,13 @@ would be possible by calling a callback more then once. | |||
| 781 | 791 | Used when an attempt is made to use crypto features while Node.js is not | |
| 782 | 792 | compiled with OpenSSL crypto support. | |
| 783 | 793 | ||
| 794 | + <a id="ERR_NO_LONGER_SUPPORTED"></a> | ||
| 795 | + ### ERR_NO_LONGER_SUPPORTED | ||
| 796 | + | ||
| 797 | + Used when a Node.js API is called in an unsupported manner. | ||
| 798 | + | ||
| 799 | + For example: `Buffer.write(string, encoding, offset[, length])` | ||
| 800 | + | ||
| 784 | 801 | <a id="ERR_PARSE_HISTORY_DATA"></a> | |
| 785 | 802 | ### ERR_PARSE_HISTORY_DATA | |
| 786 | 803 | ||
@@ -844,6 +861,11 @@ Used to identify a specific kind of internal Node.js error that should not | |||
| 844 | 861 | typically be triggered by user code. Instances of this error point to an | |
| 845 | 862 | internal bug within the Node.js binary itself. | |
| 846 | 863 | ||
| 864 | + <a id="ERR_UNKNOWN_ENCODING"></a> | ||
| 865 | + ### ERR_UNKNOWN_ENCODING | ||
| 866 | + | ||
| 867 | + Used when an invalid or unknown encoding option is passed to an API. | ||
| 868 | + | ||
| 847 | 869 | <a id="ERR_UNKNOWN_SIGNAL"></a> | |
| 848 | 870 | ### ERR_UNKNOWN_SIGNAL | |
| 849 | 871 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,9 +67,6 @@ Object.defineProperty(exports, 'constants', { | |||
| 67 | 67 | ||
| 68 | 68 | exports.kStringMaxLength = binding.kStringMaxLength; | |
| 69 | 69 | ||
| 70 | - const kFromErrorMsg = 'First argument must be a string, Buffer, ' + | ||
| 71 | - 'ArrayBuffer, Array, or array-like object.'; | ||
| 72 | - | ||
| 73 | 70 | Buffer.poolSize = 8 * 1024; | |
| 74 | 71 | var poolSize, poolOffset, allocPool; | |
| 75 | 72 | ||
@@ -146,9 +143,8 @@ function Buffer(arg, encodingOrOffset, length) { | |||
| 146 | 143 | // Common case. | |
| 147 | 144 | if (typeof arg === 'number') { | |
| 148 | 145 | if (typeof encodingOrOffset === 'string') { | |
| 149 | - throw new Error( | ||
| 150 | - 'If encoding is specified then the first argument must be a string' | ||
| 151 | - ); | ||
| 146 | + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'string', | ||
| 147 | + 'string', arg); | ||
| 152 | 148 | } | |
| 153 | 149 | return Buffer.alloc(arg); | |
| 154 | 150 | } | |
@@ -177,10 +173,12 @@ Buffer.from = function(value, encodingOrOffset, length) { | |||
| 177 | 173 | return fromArrayBuffer(value, encodingOrOffset, length); | |
| 178 | 174 | ||
| 179 | 175 | if (value == null) | |
| 180 | - throw new TypeError(kFromErrorMsg); | ||
| 176 | + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'first argument', | ||
| 177 | + ['string', 'buffer', 'arrayBuffer', 'array', 'array-like object'], value); | ||
| 181 | 178 | ||
| 182 | 179 | if (typeof value === 'number') | |
| 183 | - throw new TypeError('"value" argument must not be a number'); | ||
| 180 | + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'value', 'not number', | ||
| 181 | + value); | ||
| 184 | 182 | ||
| 185 | 183 | const valueOf = value.valueOf && value.valueOf(); | |
| 186 | 184 | if (valueOf != null && valueOf !== value) | |
@@ -196,7 +194,8 @@ Buffer.from = function(value, encodingOrOffset, length) { | |||
| 196 | 194 | length); | |
| 197 | 195 | } | |
| 198 | 196 | ||
| 199 | - throw new TypeError(kFromErrorMsg); | ||
| 197 | + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'first argument', | ||
| 198 | + ['string', 'buffer', 'arrayBuffer', 'array', 'array-like object']); | ||
| 200 | 199 | }; | |
| 201 | 200 | ||
| 202 | 201 | Object.setPrototypeOf(Buffer, Uint8Array); | |
@@ -208,12 +207,11 @@ function assertSize(size) { | |||
| 208 | 207 | let err = null; | |
| 209 | 208 | ||
| 210 | 209 | if (typeof size !== 'number') { | |
| 211 | - err = new TypeError('"size" argument must be a number'); | ||
| 210 | + err = new errors.TypeError('ERR_INVALID_ARG_TYPE', 'size', 'number', size); | ||
| 212 | 211 | } else if (size < 0) { | |
| 213 | - err = new RangeError('"size" argument must not be negative'); | ||
| 212 | + err = new errors.RangeError('ERR_INVALID_OPT_VALUE', 'size', size); | ||
| 214 | 213 | } else if (size > binding.kMaxLength) { | |
| 215 | - err = new RangeError('"size" argument must not be larger ' + | ||
| 216 | - 'than ' + binding.kMaxLength); | ||
| 214 | + err = new errors.RangeError('ERR_INVALID_OPT_VALUE', 'size', size); | ||
| 217 | 215 | } | |
| 218 | 216 | ||
| 219 | 217 | if (err) { | |
@@ -300,7 +298,7 @@ function fromString(string, encoding) { | |||
| 300 | 298 | } else { | |
| 301 | 299 | length = byteLength(string, encoding, true); | |
| 302 | 300 | if (length === -1) | |
| 303 | - throw new TypeError('"encoding" must be a valid string encoding'); | ||
| 301 | + throw new errors.TypeError('ERR_UNKNOWN_ENCODING', encoding); | ||
| 304 | 302 | if (string.length === 0) | |
| 305 | 303 | return new FastBuffer(); | |
| 306 | 304 | } | |
@@ -343,7 +341,7 @@ function fromArrayBuffer(obj, byteOffset, length) { | |||
| 343 | 341 | const maxLength = obj.byteLength - byteOffset; | |
| 344 | 342 | ||
| 345 | 343 | if (maxLength < 0) | |
| 346 | - throw new RangeError("'offset' is out of bounds"); | ||
| 344 | + throw new errors.RangeError('ERR_BUFFER_OUT_OF_BOUNDS', 'offset'); | ||
| 347 | 345 | ||
| 348 | 346 | if (length === undefined) { | |
| 349 | 347 | length = maxLength; | |
@@ -355,7 +353,7 @@ function fromArrayBuffer(obj, byteOffset, length) { | |||
| 355 | 353 | length = 0; | |
| 356 | 354 | } else if (length > 0) { | |
| 357 | 355 | if (length > maxLength) | |
| 358 | - throw new RangeError("'length' is out of bounds"); | ||
| 356 | + throw new errors.RangeError('ERR_BUFFER_OUT_OF_BOUNDS', 'length'); | ||
| 359 | 357 | } else { | |
| 360 | 358 | length = 0; | |
| 361 | 359 | } | |
@@ -399,7 +397,8 @@ Buffer.isBuffer = function isBuffer(b) { | |||
| 399 | 397 | ||
| 400 | 398 | Buffer.compare = function compare(a, b) { | |
| 401 | 399 | if (!isUint8Array(a) || !isUint8Array(b)) { | |
| 402 | - throw new TypeError('Arguments must be Buffers or Uint8Arrays'); | ||
| 400 | + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', ['buf1', 'buf2'], | ||
| 401 | + ['buffer', 'uint8Array']); | ||
| 403 | 402 | } | |
| 404 | 403 | ||
| 405 | 404 | if (a === b) { | |
@@ -416,13 +415,13 @@ Buffer.isEncoding = function(encoding) { | |||
| 416 | 415 | }; | |
| 417 | 416 | Buffer[internalUtil.kIsEncodingSymbol] = Buffer.isEncoding; | |
| 418 | 417 | ||
| 419 | - const kConcatErrMsg = '"list" argument must be an Array ' + | ||
| 420 | - 'of Buffer or Uint8Array instances'; | ||
| 418 | + const kConcatErr = new errors.TypeError('ERR_INVALID_ARG_TYPE', 'list', | ||
| 419 | + ['array', 'buffer', 'uint8Array']); | ||
| 421 | 420 | ||
| 422 | 421 | Buffer.concat = function(list, length) { | |
| 423 | 422 | var i; | |
| 424 | 423 | if (!Array.isArray(list)) | |
| 425 | - throw new TypeError(kConcatErrMsg); | ||
| 424 | + throw kConcatErr; | ||
| 426 | 425 | ||
| 427 | 426 | if (list.length === 0) | |
| 428 | 427 | return new FastBuffer(); | |
@@ -440,7 +439,7 @@ Buffer.concat = function(list, length) { | |||
| 440 | 439 | for (i = 0; i < list.length; i++) { | |
| 441 | 440 | var buf = list[i]; | |
| 442 | 441 | if (!isUint8Array(buf)) | |
| 443 | - throw new TypeError(kConcatErrMsg); | ||
| 442 | + throw kConcatErr; | ||
| 444 | 443 | binding.copy(buf, buffer, pos); | |
| 445 | 444 | pos += buf.length; | |
| 446 | 445 | } | |
@@ -475,7 +474,8 @@ function byteLength(string, encoding) { | |||
| 475 | 474 | return string.byteLength; | |
| 476 | 475 | } | |
| 477 | 476 | ||
| 478 | - throw new TypeError('"string" must be a string, Buffer, or ArrayBuffer'); | ||
| 477 | + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'string', | ||
| 478 | + ['string', 'buffer', 'arrayBuffer']); | ||
| 479 | 479 | } | |
| 480 | 480 | ||
| 481 | 481 | const len = string.length; | |
@@ -591,7 +591,7 @@ function stringSlice(buf, encoding, start, end) { | |||
| 591 | 591 | return buf.ucs2Slice(start, end); | |
| 592 | 592 | break; | |
| 593 | 593 | } | |
| 594 | - throw new TypeError('Unknown encoding: ' + encoding); | ||
| 594 | + throw new errors.TypeError('ERR_UNKNOWN_ENCODING', encoding); | ||
| 595 | 595 | } | |
| 596 | 596 | ||
| 597 | 597 | ||
@@ -633,8 +633,8 @@ Buffer.prototype.toString = function(encoding, start, end) { | |||
| 633 | 633 | ||
| 634 | 634 | Buffer.prototype.equals = function equals(b) { | |
| 635 | 635 | if (!isUint8Array(b)) | |
| 636 | - throw new TypeError('Argument must be a Buffer or Uint8Array'); | ||
| 637 | - | ||
| 636 | + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'otherBuffer', | ||
| 637 | + ['buffer', 'uint8Array']); | ||
| 638 | 638 | if (this === b) | |
| 639 | 639 | return true; | |
| 640 | 640 | ||
@@ -659,7 +659,8 @@ Buffer.prototype.compare = function compare(target, | |||
| 659 | 659 | thisStart, | |
| 660 | 660 | thisEnd) { | |
| 661 | 661 | if (!isUint8Array(target)) | |
| 662 | - throw new TypeError('Argument must be a Buffer or Uint8Array'); | ||
| 662 | + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'target', | ||
| 663 | + ['buffer', 'uint8Array']); | ||
| 663 | 664 | if (arguments.length === 1) | |
| 664 | 665 | return compare_(this, target); | |
| 665 | 666 | ||
@@ -738,8 +739,8 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { | |||
| 738 | 739 | return binding.indexOfNumber(buffer, val, byteOffset, dir); | |
| 739 | 740 | } | |
| 740 | 741 | ||
| 741 | - throw new TypeError('"val" argument must be string, number, Buffer ' + | ||
| 742 | - 'or Uint8Array'); | ||
| 742 | + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'val', | ||
| 743 | + ['string', 'buffer', 'uint8Array']); | ||
| 743 | 744 | } | |
| 744 | 745 | ||
| 745 | 746 | ||
@@ -765,7 +766,7 @@ function slowIndexOf(buffer, val, byteOffset, encoding, dir) { | |||
| 765 | 766 | ||
| 766 | 767 | default: | |
| 767 | 768 | if (loweredCase) { | |
| 768 | - throw new TypeError('Unknown encoding: ' + encoding); | ||
| 769 | + throw new errors.TypeError('ERR_UNKNOWN_ENCODING', encoding); | ||
| 769 | 770 | } | |
| 770 | 771 | ||
| 771 | 772 | encoding = ('' + encoding).toLowerCase(); | |
@@ -807,11 +808,11 @@ Buffer.prototype.fill = function fill(val, start, end, encoding) { | |||
| 807 | 808 | } | |
| 808 | 809 | ||
| 809 | 810 | if (encoding !== undefined && typeof encoding !== 'string') { | |
| 810 | - throw new TypeError('encoding must be a string'); | ||
| 811 | + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'encoding', 'string'); | ||
| 811 | 812 | } | |
| 812 | 813 | var normalizedEncoding = internalUtil.normalizeEncoding(encoding); | |
| 813 | 814 | if (normalizedEncoding === undefined) { | |
| 814 | - throw new TypeError('Unknown encoding: ' + encoding); | ||
| 815 | + throw new errors.TypeError('ERR_UNKNOWN_ENCODING', encoding); | ||
| 815 | 816 | } | |
| 816 | 817 | ||
| 817 | 818 | if (val.length === 0) { | |
@@ -872,13 +873,13 @@ Buffer.prototype.write = function(string, offset, length, encoding) { | |||
| 872 | 873 | length = remaining; | |
| 873 | 874 | ||
| 874 | 875 | if (string.length > 0 && (length < 0 || offset < 0)) | |
| 875 | - throw new RangeError('Attempt to write outside buffer bounds'); | ||
| 876 | + throw new errors.RangeError('ERR_BUFFER_OUT_OF_BOUNDS', 'length', true); | ||
| 876 | 877 | } else { | |
| 877 | 878 | // if someone is still calling the obsolete form of write(), tell them. | |
| 878 | 879 | // we don't want eg buf.write("foo", "utf8", 10) to silently turn into | |
| 879 | 880 | // buf.write("foo", "utf8"), so we can't ignore extra args | |
| 880 | - throw new Error('Buffer.write(string, encoding, offset[, length]) ' + | ||
| 881 | - 'is no longer supported'); | ||
| 881 | + throw new errors.Error('ERR_NO_LONGER_SUPPORTED', | ||
| 882 | + 'Buffer.write(string, encoding, offset[, length])'); | ||
| 882 | 883 | } | |
| 883 | 884 | ||
| 884 | 885 | if (!encoding) return this.utf8Write(string, offset, length); | |
@@ -925,7 +926,7 @@ Buffer.prototype.write = function(string, offset, length, encoding) { | |||
| 925 | 926 | return this.hexWrite(string, offset, length); | |
| 926 | 927 | break; | |
| 927 | 928 | } | |
| 928 | - throw new TypeError('Unknown encoding: ' + encoding); | ||
| 929 | + throw new errors.TypeError('ERR_UNKNOWN_ENCODING', encoding); | ||
| 929 | 930 | }; | |
| 930 | 931 | ||
| 931 | 932 | ||
@@ -1176,7 +1177,7 @@ Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { | |||
| 1176 | 1177 | ||
| 1177 | 1178 | function checkInt(buffer, value, offset, ext, max, min) { | |
| 1178 | 1179 | if (value > max || value < min) | |
| 1179 | - throw new TypeError('"value" argument is out of bounds'); | ||
| 1180 | + throw new errors.RangeError('ERR_INVALID_OPT_VALUE', 'value', value); | ||
| 1180 | 1181 | if (offset + ext > buffer.length) | |
| 1181 | 1182 | throw new errors.RangeError('ERR_INDEX_OUT_OF_RANGE'); | |
| 1182 | 1183 | } | |
@@ -1448,7 +1449,7 @@ Buffer.prototype.swap16 = function swap16() { | |||
| 1448 | 1449 | // dropping down to the native code is faster. | |
| 1449 | 1450 | const len = this.length; | |
| 1450 | 1451 | if (len % 2 !== 0) | |
| 1451 | - throw new RangeError('Buffer size must be a multiple of 16-bits'); | ||
| 1452 | + throw new errors.RangeError('ERR_INVALID_BUFFER_SIZE', '16-bits'); | ||
| 1452 | 1453 | if (len < 128) { | |
| 1453 | 1454 | for (var i = 0; i < len; i += 2) | |
| 1454 | 1455 | swap(this, i, i + 1); | |
@@ -1464,7 +1465,7 @@ Buffer.prototype.swap32 = function swap32() { | |||
| 1464 | 1465 | // dropping down to the native code is faster. | |
| 1465 | 1466 | const len = this.length; | |
| 1466 | 1467 | if (len % 4 !== 0) | |
| 1467 | - throw new RangeError('Buffer size must be a multiple of 32-bits'); | ||
| 1468 | + throw new errors.RangeError('ERR_INVALID_BUFFER_SIZE', '32-bits'); | ||
| 1468 | 1469 | if (len < 192) { | |
| 1469 | 1470 | for (var i = 0; i < len; i += 4) { | |
| 1470 | 1471 | swap(this, i, i + 3); | |
@@ -1482,7 +1483,7 @@ Buffer.prototype.swap64 = function swap64() { | |||
| 1482 | 1483 | // dropping down to the native code is faster. | |
| 1483 | 1484 | const len = this.length; | |
| 1484 | 1485 | if (len % 8 !== 0) | |
| 1485 | - throw new RangeError('Buffer size must be a multiple of 64-bits'); | ||
| 1486 | + throw new errors.RangeError('ERR_INVALID_BUFFER_SIZE', '64-bits'); | ||
| 1486 | 1487 | if (len < 192) { | |
| 1487 | 1488 | for (var i = 0; i < len; i += 8) { | |
| 1488 | 1489 | swap(this, i, i + 7); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -109,9 +109,11 @@ module.exports = exports = { | |||
| 109 | 109 | // Note: Please try to keep these in alphabetical order | |
| 110 | 110 | E('ERR_ARG_NOT_ITERABLE', '%s must be iterable'); | |
| 111 | 111 | E('ERR_ASSERTION', '%s'); | |
| 112 | + E('ERR_BUFFER_OUT_OF_BOUNDS', bufferOutOfBounds); | ||
| 112 | 113 | E('ERR_CONSOLE_WRITABLE_STREAM', | |
| 113 | 114 | 'Console expects a writable stream instance for %s'); | |
| 114 | 115 | E('ERR_CPU_USAGE', 'Unable to obtain cpu usage %s'); | |
| 116 | + E('ERR_NO_LONGER_SUPPORTED', '%s is no longer supported'); | ||
| 115 | 117 | E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value'); | |
| 116 | 118 | E('ERR_HTTP_HEADERS_SENT', | |
| 117 | 119 | 'Cannot render headers after they are sent to the client'); | |
@@ -127,6 +129,7 @@ E('ERR_INVALID_ARRAY_LENGTH', | |||
| 127 | 129 | return `The "${name}" array must have a length of ${ | |
| 128 | 130 | length}. Received length ${actual}`; | |
| 129 | 131 | }); | |
| 132 | + E('ERR_INVALID_BUFFER_SIZE', 'Buffer size must be a multiple of %s'); | ||
| 130 | 133 | E('ERR_INVALID_CALLBACK', 'Callback must be a function'); | |
| 131 | 134 | E('ERR_INVALID_CHAR', 'Invalid character in %s'); | |
| 132 | 135 | E('ERR_INVALID_CURSOR_POS', | |
@@ -173,6 +176,7 @@ E('ERR_TRANSFORM_ALREADY_TRANSFORMING', | |||
| 173 | 176 | 'Calling transform done when still transforming'); | |
| 174 | 177 | E('ERR_TRANSFORM_WITH_LENGTH_0', | |
| 175 | 178 | 'Calling transform done when writableState.length != 0'); | |
| 179 | + E('ERR_UNKNOWN_ENCODING', 'Unknown encoding: %s'); | ||
| 176 | 180 | E('ERR_UNKNOWN_SIGNAL', 'Unknown signal: %s'); | |
| 177 | 181 | E('ERR_UNKNOWN_STDIN_TYPE', 'Unknown stdin file type'); | |
| 178 | 182 | E('ERR_UNKNOWN_STREAM_TYPE', 'Unknown stream file type'); | |
@@ -183,8 +187,29 @@ E('ERR_V8BREAKITERATOR', 'Full ICU data not installed. ' + | |||
| 183 | 187 | function invalidArgType(name, expected, actual) { | |
| 184 | 188 | const assert = lazyAssert(); | |
| 185 | 189 | assert(name, 'name is required'); | |
| 186 | - const type = name.includes('.') ? 'property' : 'argument'; | ||
| 187 | - var msg = `The "${name}" ${type} must be ${oneOf(expected, 'type')}`; | ||
| 190 | + | ||
| 191 | + // determiner: 'must be' or 'must not be' | ||
| 192 | + let determiner; | ||
| 193 | + if (expected.includes('not ')) { | ||
| 194 | + determiner = 'must not be'; | ||
| 195 | + expected = expected.split('not ')[1]; | ||
| 196 | + } else { | ||
| 197 | + determiner = 'must be'; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + let msg; | ||
| 201 | + if (Array.isArray(name)) { | ||
| 202 | + var names = name.map((val) => `"${val}"`).join(', '); | ||
| 203 | + msg = `The ${names} arguments ${determiner} ${oneOf(expected, 'type')}`; | ||
| 204 | + } else if (name.includes(' argument')) { | ||
| 205 | + // for the case like 'first argument' | ||
| 206 | + msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`; | ||
| 207 | + } else { | ||
| 208 | + const type = name.includes('.') ? 'property' : 'argument'; | ||
| 209 | + msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`; | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + // if actual value received, output it | ||
| 188 | 213 | if (arguments.length >= 3) { | |
| 189 | 214 | msg += `. Received type ${actual !== null ? typeof actual : 'null'}`; | |
| 190 | 215 | } | |
@@ -231,3 +256,11 @@ function oneOf(expected, thing) { | |||
| 231 | 256 | return `of ${thing} ${String(expected)}`; | |
| 232 | 257 | } | |
| 233 | 258 | } | |
| 259 | + | ||
| 260 | + function bufferOutOfBounds(name, isWriting) { | ||
| 261 | + if (isWriting) { | ||
| 262 | + return 'Attempt to write outside buffer bounds'; | ||
| 263 | + } else { | ||
| 264 | + return `"${name}" is outside of buffer bounds`; | ||
| 265 | + } | ||
| 266 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments