From f77a87171f211cad75688f6a8281cca7ef46e573 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 17 Jan 2018 03:35:50 -0800 Subject: [PATCH] Handle non-JS-provided error handlers when generating a config from a sync session (#1616) --- src/js_sync.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/js_sync.hpp b/src/js_sync.hpp index 8a57aaa6..238ab94c 100644 --- a/src/js_sync.hpp +++ b/src/js_sync.hpp @@ -390,9 +390,10 @@ void SessionClass::get_config(ContextType ctx, ObjectType object, ReturnValue ObjectType config = Object::create_empty(ctx); Object::set_property(ctx, config, "user", create_object>(ctx, new SharedUser(session->config().user))); Object::set_property(ctx, config, "url", Value::from_string(ctx, session->config().realm_url())); - if (auto* dispatcher = session->config().error_handler.template target>()) { - auto& handler = *dispatcher->func().template target>(); - Object::set_property(ctx, config, "error", handler.func()); + if (auto dispatcher = session->config().error_handler.template target>()) { + if (auto handler = dispatcher->func().template target>()) { + Object::set_property(ctx, config, "error", handler->func()); + } } return_value.set(config); } else {