diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index 396662c9..b82972d3 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -610,11 +610,9 @@ export class WhatsappDirectLine extends GBService { }); watermark = response.obj.watermark; await this.printMessages(response.obj.activities, conversationId, from, fromName); - } catch (err) { + } catch (error) { GBLog.error( - `Error calling printMessages on Whatsapp channel ${err.data === undefined ? - err : err.data} ${err.errObj ? err.errObj.message : '' - }` + `Error calling printMessages on Whatsapp channel ${JSON.stringify(error)}` ); } }; diff --git a/src/app.ts b/src/app.ts index 4be4abbb..8dd30afd 100644 --- a/src/app.ts +++ b/src/app.ts @@ -111,15 +111,13 @@ export class GBServer { }); process.on('uncaughtException', (err, p) => { - if (err !== null) { - err = err['e'] ? err['e'] : err; - const msg = `${err['code'] ? err['code'] : ''} ${err?.['response']?.['data'] ? err?.['response']?.['data'] : ''} ${err.message ? err.message : ''} ${err['description'] ? err['description'] : ''}` - GBLog.error(`UNCAUGHT_EXCEPTION: ${err.toString()} ${err['stack'] ? '\n' + err['stack'] : ''} ${msg}`); - } else { - GBLog.error('UNCAUGHT_EXCEPTION: Unknown error (err is null)'); - } + GBLog.error(`UNCAUGHT_EXCEPTION: ${JSON.stringify(err).}`); }); - // Creates working directory. + + process.on('unhandledRejection', (err, p) => { + GBLog.error(`UNHANDLED_REJECTION: ${JSON.stringify(err).}`); + }); + // Creates working directory. process.env.PWD = process.cwd(); const workDir = Path.join(process.env.PWD, 'work');