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

document when to use error!type in function decl #768

Closed
wants to merge 1 commit into from
Closed

document when to use error!type in function decl #768

wants to merge 1 commit into from

Conversation

bnoordhuis
Copy link
Contributor

No description provided.

@andrewrk
Copy link
Member

andrewrk commented Feb 9, 2018

I'm going to leave this PR open until I go through the docs and rewrite / add content for error sets, and merge it in manually.

@bnoordhuis
Copy link
Contributor Author

Don't worry, feel free to close if you're rewriting the docs anyway. Also happy to rebase when you're done.

@andrewrk andrewrk closed this in 8db7a14 Feb 24, 2018
@andrewrk
Copy link
Member

I added a little bit to the docs on errors. Here's what I ended up writing:

The Global Error Set

error refers to the global error set. This is the error set that contains all errors in the entire compilation unit. It is a superset of all other error sets and a subset of none of them.

You can implicitly cast any error set to the global one, and you can explicitly cast an error of global error set to a non-global one. This inserts a language-level assert to make sure the error value is in fact in the destination error set.

The global error set should generally be avoided when possible, because it prevents the compiler from knowing what errors are possible at compile-time. Knowing the error set at compile-time is better for generated documentationt and for helpful error messages such as forgetting a possible error value in a switch.

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.

None yet

2 participants