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

From Discord: Handling Missing 'cause' in @effect/schema Exceptions #2729

Closed
effect-bot opened this issue May 11, 2024 · 0 comments · Fixed by #2738 or #2739
Closed

From Discord: Handling Missing 'cause' in @effect/schema Exceptions #2729

effect-bot opened this issue May 11, 2024 · 0 comments · Fixed by #2738 or #2739
Labels

Comments

@effect-bot
Copy link

Summary

The discussion revolves around identifying exceptions generated by @effect/schema when using its functionality, particularly when some exceptions do not include a cause property, which would ideally contain the parse issue. Here are the key points and takeaways from the conversation:

  1. Issue with cause Property: The initial problem highlighted is that not all errors thrown by @effect/schema operations, such as decodeSync, include a cause property. This property is crucial for understanding the underlying issue when an error occurs, especially when working with a top-level error boundary to catch unhandled exceptions.

  2. Example of Missing cause: A specific example was provided where calling S.decodeSync(S.String)(42) results in an error without a cause, making it challenging to detect and handle errors specific to @effect/schema.

  3. Advice on Error Handling: It was suggested to use decode instead of decodeSync for fully typed errors, indicating that decode might provide more detailed error information, including the cause.

  4. Version Update Recommendation: To address the issue with missing cause properties, upgrading to the latest version of the library (version 0.67 at the time of the conversation) was recommended. This version presumably includes improvements to error handling, ensuring that more, if not all, errors include a cause.

  5. Acknowledgment of Oversight: It was acknowledged that the absence of a cause in errors thrown by asserts is an oversight, with a commitment to fix this issue. However, it was also mentioned that errors from operations like decodeSync should already have the cause covered in the mentioned version.

Key Takeaways:

  • Upgrading to the latest version of @effect/schema is crucial for better error handling and to ensure errors include a cause where expected.
  • Using decode over decodeSync might offer more detailed and fully typed errors, beneficial for debugging and error handling.
  • The library maintainers are aware of the issues regarding error handling and are committed to making improvements, indicating ongoing support and development of the library.

Discord thread

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

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