-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
sqlite: handle exceptions in filter callback database.applyChangeset() #56903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -825,13 +825,21 @@ void DatabaseSync::ApplyChangeset(const FunctionCallbackInfo<Value>& args) { | |||||||
| Local<Function> filterFunc = filterValue.As<Function>(); | ||||||||
|
|
||||||||
| filterCallback = [env, filterFunc](std::string item) -> bool { | ||||||||
| TryCatch try_catch(env->isolate()); | ||||||||
| Local<Value> argv[] = {String::NewFromUtf8(env->isolate(), | ||||||||
| item.c_str(), | ||||||||
| NewStringType::kNormal) | ||||||||
| .ToLocalChecked()}; | ||||||||
| Local<Value> result = | ||||||||
| filterFunc->Call(env->context(), Null(env->isolate()), 1, argv) | ||||||||
| .ToLocalChecked(); | ||||||||
| item.c_str(), | ||||||||
| NewStringType::kNormal) | ||||||||
| .ToLocalChecked()}; | ||||||||
| MaybeLocal<Value> maybe_result = | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need the |
||||||||
| filterFunc->Call(env->context(), Null(env->isolate()), 1, argv); | ||||||||
| if (try_catch.HasCaught()) { | ||||||||
| try_catch.ReThrow(); | ||||||||
| return false; | ||||||||
| } | ||||||||
|
Comment on lines
+837
to
+839
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not technically wrong, but you don't need this because you already handle the
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will still add some logic here, I think this branch is taken when an exception is thrown, correct?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it should be taken when |
||||||||
| if (maybe_result.IsEmpty()) { | ||||||||
| return false; | ||||||||
| } | ||||||||
| Local<Value> result = maybe_result.ToLocalChecked(); | ||||||||
| return result->BooleanValue(env->isolate()); | ||||||||
| }; | ||||||||
| } | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.