From c9f375a151cc8caa74c341f054e8a3e0cdc96b52 Mon Sep 17 00:00:00 2001 From: cel Date: Fri, 8 Nov 2019 14:16:37 -1000 Subject: Handle synchronous error in ssb.get --- lib/app.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/app.js b/lib/app.js index 4119179..3d8d507 100644 --- a/lib/app.js +++ b/lib/app.js @@ -491,13 +491,17 @@ function getMsgWithValue(sbot, id, cb) { var parts = id.split('?unbox=') id = parts[0] var unbox = parts[1] && parts[1].replace(/ /g, '+') - sbotGet(sbot, id, function (err, value) { - if (err) return cb(err) - var msg = {key: id, value: value} - if (unbox && value && typeof value.content === 'string') - return self.app.unboxMsgWithKey(msg, unbox, cb) - cb(null, msg) - }) + try { + sbotGet(sbot, id, function (err, value) { + if (err) return cb(err) + var msg = {key: id, value: value} + if (unbox && value && typeof value.content === 'string') + return self.app.unboxMsgWithKey(msg, unbox, cb) + cb(null, msg) + }) + } catch(e) { + return cb(e) + } } App.prototype._getAbout = function (id, cb) { -- cgit v1.2.3