Skip to content

Document built-in exceptions #880

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

Merged
merged 4 commits into from
Jun 12, 2024
Merged

Conversation

aspeddro
Copy link
Collaborator

@aspeddro aspeddro commented Jun 8, 2024

Close #872

@aspeddro aspeddro self-assigned this Jun 8, 2024
Copy link

vercel bot commented Jun 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rescript-lang.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2024 0:19am

@@ -6,9 +6,36 @@ canonical: "/docs/manual/latest/exception"

# Exception

Exceptions are just a special kind of variant, thrown in **exceptional** cases (don't abuse them!).
Exceptions are just a special kind of variant, thrown in **exceptional** cases (don't abuse them!). Consider using the `option` or `result` type for recoverable errors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to the corresponding docs page(s) for Option and Result please.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have documented the result builtin type

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add Result page after Null, Undefined and Option

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added link to option 8544ec9

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Yes we need to document Result somewhere, but we can fix the link afterwards.
Or just link to the Core Result Api page for now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also make your own exceptions like you'd make a variant (exceptions need to be capitalized too).
### `Invalid_argument`

Used to check if argument is valid. This exception takes a string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget the .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error: new Error()
};
Exception raised to signal that the given arguments do not make sense. This
exception take a string as argument.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

takes a string as an argument

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fhammerschmidt fhammerschmidt merged commit 9f59348 into master Jun 12, 2024
3 checks passed
@fhammerschmidt fhammerschmidt deleted the document-builtin-exceptions branch June 12, 2024 13:21
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

Successfully merging this pull request may close these issues.

Where can I find all the built-in exception documentation, like Not_found?
2 participants