aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-11-08 14:16:37 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-11-08 14:46:09 -1000
commitc9f375a151cc8caa74c341f054e8a3e0cdc96b52 (patch)
treecd5c730fc6bc29f5483e9612e7cfe0b3066c46bd
parentcd7ba4c502956c3e39d127492732ba6f95cb33e5 (diff)
downloadpatchfoo-c9f375a151cc8caa74c341f054e8a3e0cdc96b52.tar.gz
patchfoo-c9f375a151cc8caa74c341f054e8a3e0cdc96b52.zip
Handle synchronous error in ssb.get
-rw-r--r--lib/app.js18
1 files 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) {