Skip to content

Commit

Permalink
fix: Fix formatting for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Mar 15, 2022
1 parent de5326b commit f442525
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions ios/MmkvHostObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
const jsi::Value& thisValue,
const jsi::Value* arguments,
size_t count) -> jsi::Value {
if (!arguments[0].isString()) throw jsi::JSError(runtime, "MMKV::set: First argument ('key') has to be of type string!");
if (!arguments[0].isString()) {
throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
}

auto keyName = convertJSIStringToNSString(runtime, arguments[0].getString(runtime));

if (arguments[1].isBool()) {
Expand All @@ -74,8 +77,9 @@
auto stringValue = convertJSIStringToNSString(runtime, arguments[1].getString(runtime));
[instance setString:stringValue forKey:keyName];
} else {
throw jsi::JSError(runtime, "MMKV::set: 'value' argument is not of type bool, number or string!");
throw jsi::JSError(runtime, "Second argument ('value') has to be of type bool, number or string!");
}

return jsi::Value::undefined();
});
}
Expand All @@ -89,7 +93,9 @@
const jsi::Value& thisValue,
const jsi::Value* arguments,
size_t count) -> jsi::Value {
if (!arguments[0].isString()) throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
if (!arguments[0].isString()) {
throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
}

auto keyName = convertJSIStringToNSString(runtime, arguments[0].getString(runtime));
bool value = [instance getBoolForKey:keyName];
Expand All @@ -106,7 +112,9 @@
const jsi::Value& thisValue,
const jsi::Value* arguments,
size_t count) -> jsi::Value {
if (!arguments[0].isString()) throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
if (!arguments[0].isString()) {
throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
}

auto keyName = convertJSIStringToNSString(runtime, arguments[0].getString(runtime));
auto value = [instance getStringForKey:keyName];
Expand All @@ -126,7 +134,9 @@
const jsi::Value& thisValue,
const jsi::Value* arguments,
size_t count) -> jsi::Value {
if (!arguments[0].isString()) throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
if (!arguments[0].isString()) {
throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
}

auto keyName = convertJSIStringToNSString(runtime, arguments[0].getString(runtime));
auto value = [instance getDoubleForKey:keyName];
Expand All @@ -143,7 +153,9 @@
const jsi::Value& thisValue,
const jsi::Value* arguments,
size_t count) -> jsi::Value {
if (!arguments[0].isString()) throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
if (!arguments[0].isString()) {
throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
}

auto keyName = convertJSIStringToNSString(runtime, arguments[0].getString(runtime));
bool containsKey = [instance containsKey:keyName];
Expand All @@ -160,7 +172,9 @@
const jsi::Value& thisValue,
const jsi::Value* arguments,
size_t count) -> jsi::Value {
if (!arguments[0].isString()) throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
if (!arguments[0].isString()) {
throw jsi::JSError(runtime, "First argument ('key') has to be of type string!");
}

auto keyName = convertJSIStringToNSString(runtime, arguments[0].getString(runtime));
[instance removeValueForKey:keyName];
Expand Down

0 comments on commit f442525

Please sign in to comment.