LibWeb/WebIDL: Throw correct error when converting integers

When an integer doesn't fit within the range of an integral type
defined by WebIDL, the spec says to throw a `TypeError`, not a
`RangeError`.
This commit is contained in:
Diego Frias 2024-08-17 15:56:38 -07:00 committed by Ali Mohammad Pur
commit 3be7e88903
Notes: github-actions[bot] 2024-08-18 21:36:08 +00:00
2 changed files with 2 additions and 2 deletions

View file

@ -384,7 +384,7 @@ JS::ThrowCompletionOr<T> convert_to_int(JS::VM& vm, JS::Value value, EnforceRang
// 3. If x < lowerBound or x > upperBound, then throw a TypeError.
if (x < lower_bound || x > upper_bound)
return vm.throw_completion<JS::RangeError>(MUST(String::formatted("Number '{}' is outside of allowed range of {} to {}", x, lower_bound, upper_bound)));
return vm.throw_completion<JS::TypeError>(MUST(String::formatted("Number '{}' is outside of allowed range of {} to {}", x, lower_bound, upper_bound)));
// 4. Return x.
return x;