effect icon indicating copy to clipboard operation
effect copied to clipboard

Add log level option to Effect.ignoreLogged

Open effect-bot opened this issue 2 years ago • 1 comments

Summary

The user was looking for a way to ignore errors in JavaScript without doing anything with them. They initially used Effect.catchAll(() => Effect.ignore(Effect.unit)), but were unsure if there was a better way to achieve this. They were specifically interested in logging the errors they were ignoring.

After some discussion, it was suggested to use Effect.ignoreLogged to ignore the errors and log them. However, it seems that Effect.ignoreLogged was not logging the errors as expected. The user then tried using Effect.tapError with Console.log to manually log the errors, which worked for them.

Key takeaways:

  1. In JavaScript, it is not possible to completely ignore errors without doing anything with them. You need to handle them in some way, even if it means logging them and moving on.
  2. Effect.ignoreLogged should log the errors it ignores, but it may not work as expected in some cases. Manually logging the errors using Effect.tapError and Console.log can be a workaround.
  3. It's important to consider the logging level when using Effect.ignoreLogged. Adjusting the minimum log level using Logger.withMinimumLogLevel can help ensure that the errors are logged in the desired mode.

Discord thread

https://discord.com/channels/795981131316985866/1167484615804596354

effect-bot avatar Oct 27 '23 17:10 effect-bot

Takeaway: add a log level param to ignoreLogged

mikearnaldi avatar Oct 27 '23 17:10 mikearnaldi