commit 8e6f15f4cba2c558059c3a421710a23147d861a4
parent 9723544e3a19dc70ab808d4c20834777c174f022
Author: William Casarin <jb55@jb55.com>
Date: Fri, 18 Nov 2022 06:06:30 -0800
fix some crashes
Diffstat:
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/nostr-events.js b/nostr-events.js
@@ -74,7 +74,15 @@ async function plugin_init(params) {
const evName = Object.keys(params)[0]
if (!eventList.includes(evName)) return
- let res = await handle_msg(notify_pk, evName, params)
+ let res = null
+ try {
+ res = await handle_msg(notify_pk, evName, params)
+ } catch (e) {
+ await send_msg(pool, privkey, pubkey, {
+ content: `An error was thrown when handling the '${evName}' event: ${e.toString()}`
+ })
+ return
+ }
if (res === null)
return
if (typeof res === "string")
@@ -114,7 +122,11 @@ function parse_msats(str)
if (!str) {
return 0
}
- return +str.replace("msat","")
+
+ if (typeof str !== 'string')
+ return str
+
+ return +(str.replace("msat",""))
}
function mksats(str)