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

Add optional message to Option.getExn #212

Merged
merged 6 commits into from
Apr 19, 2024
Merged

Add optional message to Option.getExn #212

merged 6 commits into from
Apr 19, 2024

Conversation

zth
Copy link
Collaborator

@zth zth commented Apr 18, 2024

This cherry picks the expect style function from #57, now that we focus on uncurried mode only, and therefore can add trailing optional arguments with no issues.

@zth zth requested a review from cknitt April 18, 2024 16:44
| None =>
Core__Error.panic(
switch message {
| None => "Not found."
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the implementation of panic, this means that by default an Error will be raised with the message "Panic! Not found." which sounds a bit weird to me.

Not sure what would be a better message, maybe something like
"Panic! Option.getExn called for None value"
?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, better. Changing.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about using a custom exception? It could be in a different function though.

@zth zth requested a review from cknitt April 19, 2024 08:15
@zth zth merged commit a48ceda into main Apr 19, 2024
6 checks passed
@zth zth deleted the option-getexn-message branch April 19, 2024 14:34
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.

3 participants