summaryrefslogtreecommitdiff
path: root/Userland/Applications/Spreadsheet/JSIntegration.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-10-12 19:24:57 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-13 09:55:10 +0100
commit52976bfac675f9166fd1a9bf0bf6082e4615a086 (patch)
tree7cb7b7971db2f4df59472b7887b1304c38b94e30 /Userland/Applications/Spreadsheet/JSIntegration.cpp
parent9eb065a1f62f34f62f2484139cf3063ef42565dd (diff)
downloadserenity-52976bfac675f9166fd1a9bf0bf6082e4615a086.zip
LibJS: Convert to_object() to ThrowCompletionOr
Diffstat (limited to 'Userland/Applications/Spreadsheet/JSIntegration.cpp')
-rw-r--r--Userland/Applications/Spreadsheet/JSIntegration.cpp28
1 files changed, 7 insertions, 21 deletions
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<SheetGlobalObject>(this_object)) {
vm.throw_exception<JS::TypeError>(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<SheetGlobalObject>(this_object)) {
vm.throw_exception<JS::TypeError>(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<SheetGlobalObject>(this_object)) {
vm.throw_exception<JS::TypeError>(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<SheetGlobalObject>(this_object)) {
vm.throw_exception<JS::TypeError>(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<SheetGlobalObject>(this_object)) {
vm.throw_exception<JS::TypeError>(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<SheetGlobalObject>(this_object)) {
vm.throw_exception<JS::TypeError>(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<WorkbookObject>(this_object)) {
vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotAnObjectOfType, "WorkbookObject");