From 52976bfac675f9166fd1a9bf0bf6082e4615a086 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 12 Oct 2021 19:24:57 +0100 Subject: LibJS: Convert to_object() to ThrowCompletionOr --- .../Applications/Spreadsheet/JSIntegration.cpp | 28 ++++++---------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'Userland/Applications/Spreadsheet/JSIntegration.cpp') diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp index 565a8ad942..071cd6c935 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.cpp +++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp @@ -171,9 +171,7 @@ void SheetGlobalObject::visit_edges(Visitor& visitor) JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents) { - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return JS::js_null(); + auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); if (!is(this_object)) { vm.throw_exception(global_object, JS::ErrorType::NotAnObjectOfType, "SheetGlobalObject"); @@ -210,9 +208,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents) JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::set_real_cell_contents) { - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return JS::js_null(); + auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); if (!is(this_object)) { vm.throw_exception(global_object, JS::ErrorType::NotAnObjectOfType, "SheetGlobalObject"); @@ -251,9 +247,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::set_real_cell_contents) JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::parse_cell_name) { - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return JS::js_null(); + auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); if (!is(this_object)) { vm.throw_exception(global_object, JS::ErrorType::NotAnObjectOfType, "SheetGlobalObject"); @@ -289,9 +283,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::current_cell_position) return {}; } - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return JS::js_null(); + auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); if (!is(this_object)) { vm.throw_exception(global_object, JS::ErrorType::NotAnObjectOfType, "SheetGlobalObject"); @@ -327,9 +319,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::column_index) auto& column_name_str = column_name.as_string().string(); - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return JS::js_null(); + auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); if (!is(this_object)) { vm.throw_exception(global_object, JS::ErrorType::NotAnObjectOfType, "SheetGlobalObject"); @@ -368,9 +358,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::column_arithmetic) auto offset_number = offset.as_i32(); - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return JS::js_null(); + auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); if (!is(this_object)) { vm.throw_exception(global_object, JS::ErrorType::NotAnObjectOfType, "SheetGlobalObject"); @@ -423,9 +411,7 @@ JS_DEFINE_NATIVE_FUNCTION(WorkbookObject::sheet) return {}; } - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return {}; + auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); if (!is(this_object)) { vm.throw_exception(global_object, JS::ErrorType::NotAnObjectOfType, "WorkbookObject"); -- cgit v1.2.3