|
21 | 21 |
|
22 | 22 | #include "node.h"
|
23 | 23 | #include "node_buffer.h"
|
| 24 | +#include "node_errors.h" |
24 | 25 |
|
25 | 26 | #include "env-inl.h"
|
26 | 27 | #include "string_bytes.h"
|
|
38 | 39 |
|
39 | 40 | #define THROW_AND_RETURN_IF_OOB(r) \
|
40 | 41 | do { \
|
41 |
| - if (!(r)) return env->ThrowRangeError("Index out of range"); \ |
| 42 | + if (!(r)) return node::THROW_ERR_INDEX_OUT_OF_RANGE(env); \ |
42 | 43 | } while (0)
|
43 | 44 |
|
44 | 45 | #define SLICE_START_END(start_arg, end_arg, end_max) \
|
@@ -544,7 +545,7 @@ void Copy(const FunctionCallbackInfo<Value> &args) {
|
544 | 545 | return args.GetReturnValue().Set(0);
|
545 | 546 |
|
546 | 547 | if (source_start > ts_obj_length)
|
547 |
| - return env->ThrowRangeError("Index out of range"); |
| 548 | + return node::THROW_ERR_INDEX_OUT_OF_RANGE(env); |
548 | 549 |
|
549 | 550 | if (source_end - source_start > target_length - target_start)
|
550 | 551 | source_end = source_start + target_length - target_start;
|
@@ -728,9 +729,9 @@ void CompareOffset(const FunctionCallbackInfo<Value> &args) {
|
728 | 729 | THROW_AND_RETURN_IF_OOB(ParseArrayIndex(args[5], ts_obj_length, &source_end));
|
729 | 730 |
|
730 | 731 | if (source_start > ts_obj_length)
|
731 |
| - return env->ThrowRangeError("Index out of range"); |
| 732 | + return node::THROW_ERR_INDEX_OUT_OF_RANGE(env); |
732 | 733 | if (target_start > target_length)
|
733 |
| - return env->ThrowRangeError("Index out of range"); |
| 734 | + return node::THROW_ERR_INDEX_OUT_OF_RANGE(env); |
734 | 735 |
|
735 | 736 | CHECK_LE(source_start, source_end);
|
736 | 737 | CHECK_LE(target_start, target_end);
|
|
0 commit comments