From 342f42952b9348faaa8cb461c395afd1f102af7b Mon Sep 17 00:00:00 2001 From: Elin Angelow Date: Fri, 7 Jun 2024 09:24:04 +0300 Subject: [PATCH] fix: error handling --- lib/methods/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/methods/index.js b/lib/methods/index.js index fd6971c..c31b603 100644 --- a/lib/methods/index.js +++ b/lib/methods/index.js @@ -32,7 +32,7 @@ const Methods = ({ return class methods { constructor () { - wires.register((...args) => this.test(...args)); + wires.register(async(...args) => await this.test(...args)); this.namespace = config?.namespace || ''; this.uid = uidCounter(); } @@ -170,7 +170,7 @@ const Methods = ({ let mr = data; try { if (mr.method === mr.meta?.caller) { // this is response, it calls auto generated fn that resolves promise only - return m.fn(data); + return await m.fn(data); } const r = await Promise.resolve( m.fn( @@ -188,7 +188,7 @@ const Methods = ({ mr.params = r; } catch (e) { mr.params = undefined; - mr.error = e?.error?.stack || e?.stack; + mr.error = e?.error?.stack || e?.stack || e?.error || e; this.log('error', 'Methods', mr.error, callData); } if (!data.id) {