Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to catch Forbidden error #104

Open
imsamdez opened this issue Jan 24, 2024 · 1 comment
Open

Unable to catch Forbidden error #104

imsamdez opened this issue Jan 24, 2024 · 1 comment

Comments

@imsamdez
Copy link

imsamdez commented Jan 24, 2024

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)
@curusarn
Copy link
Contributor

curusarn commented Jan 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants