Unable to catch Forbidden error
I'm having a Forbidden error when I pause a source in BetterStack.
I tried to wrap my logtail.debug calls into a try/catch or followed them with a .catch but it seems that the error is happening in the core of your lib.
By not being able to catch, it creates unnecessary noises in my logs files.
Do you have any idea how to catch the error ?
Here is the error btw
Error: Forbidden
at Node.sync [as _sync] (node_modules/@logtail/node/src/node.ts:37:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at handler (node_modules/@logtail/tools/src/throttle.ts:34:23)
Hi @imsamdez,
Thank you for reaching out!
You can pass throwExceptions: true option to make the library throw exceptions. You should be able to catch the errors then to prevent them from creating noise in your logs. Alternatively, you can use ignoreExceptions: true option to make the library ignore errors.
Let me know if this would work for you. 🙏
// If true, errors when sending logs will be ignored
// Has precedence over throwExceptions
ignoreExceptions: false,
// If true, errors when sending logs will result in a thrown exception
throwExceptions: false,
https://github.com/logtail/logtail-js/blob/master/packages/core/src/base.ts#L39