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

Rework errors concepts and exercise #2666

Merged
merged 10 commits into from
Jun 26, 2023

Conversation

junedev
Copy link
Member

@junedev junedev commented Apr 13, 2023

Next part of #2492

@junedev junedev added the x:rep/large Large amount of reputation label Apr 13, 2023
@junedev junedev marked this pull request as ready for review June 17, 2023 19:14

You do not have to always implement the error interface yourself.
To create a simple error, you can use the `errors.New()` function that is part of the standard library package `errors`.
The only thing you need to pass in is the error message as 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.

Suggested change
The only thing you need to pass in is the error message as a string.
The only thing you need to pass in is the error message as a string, and `errors.New()` will take care of creating a value that implements the `error` interface for you, containing the error message provided.

Added this to clarify that there's nothing magical about errors.New() and that is more of a utility function rather than a special way to create errors.

Feel free to reword or change sentences around.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I reworded it a bit and applied it in all the places.

Comment on lines +52 to +53
By convention, the error message should start with a lowercase letter and not end with a period.

Copy link
Member

Choose a reason for hiding this comment

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

Should we include an example of a good message vs a bad one, or do you think one can easily pick this by the other examples in the text?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this bit is important enough that we need those examples right now. If someone starts their error messages with uppercase in their real code, so be it, no harm is done as long as they have meaningful messages.

@junedev junedev merged commit 373215e into exercism:main Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:rep/large Large amount of reputation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants