diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-10-17 23:33:35 +0300 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2021-10-18 08:01:38 +0300 |
commit | f6a5ff7b003930a1994c0f4c4a1c4b1da7c7123d (patch) | |
tree | 0a7cce77a5d3f9f81444ffb22047b4944e8be28d /Userland/Libraries/LibWeb/Bindings | |
parent | 20d990563cf858d51d4c6bf93a7c37317c5ecd12 (diff) | |
download | serenity-f6a5ff7b003930a1994c0f4c4a1c4b1da7c7123d.zip |
LibJS: Convert to_i32() to ThrowCompletionOr
Diffstat (limited to 'Userland/Libraries/LibWeb/Bindings')
-rw-r--r-- | Userland/Libraries/LibWeb/Bindings/WindowObject.cpp | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp index 9eed2cebd5..fe0e377f32 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -251,9 +251,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::set_interval) } i32 interval = 0; if (vm.argument_count() >= 2) { - interval = vm.argument(1).to_i32(global_object); - if (vm.exception()) - return {}; + interval = TRY_OR_DISCARD(vm.argument(1).to_i32(global_object)); if (interval < 0) interval = 0; } @@ -290,9 +288,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::set_timeout) } i32 interval = 0; if (vm.argument_count() >= 2) { - interval = vm.argument(1).to_i32(global_object); - if (vm.exception()) - return {}; + interval = TRY_OR_DISCARD(vm.argument(1).to_i32(global_object)); if (interval < 0) interval = 0; } @@ -310,9 +306,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::clear_timeout) vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::BadArgCountAtLeastOne, "clearTimeout"); return {}; } - i32 timer_id = vm.argument(0).to_i32(global_object); - if (vm.exception()) - return {}; + i32 timer_id = TRY_OR_DISCARD(vm.argument(0).to_i32(global_object)); impl->clear_timeout(timer_id); return JS::js_undefined(); } @@ -326,9 +320,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::clear_interval) vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::BadArgCountAtLeastOne, "clearInterval"); return {}; } - i32 timer_id = vm.argument(0).to_i32(global_object); - if (vm.exception()) - return {}; + i32 timer_id = TRY_OR_DISCARD(vm.argument(0).to_i32(global_object)); impl->clear_interval(timer_id); return JS::js_undefined(); } @@ -359,9 +351,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::cancel_animation_frame) vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::BadArgCountOne, "cancelAnimationFrame"); return {}; } - auto id = vm.argument(0).to_i32(global_object); - if (vm.exception()) - return {}; + auto id = TRY_OR_DISCARD(vm.argument(0).to_i32(global_object)); impl->cancel_animation_frame(id); return JS::js_undefined(); } |