[v3] Implement new Concept Exercise: errors
Getting started
Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:
Please also watch the following video:
Goal
The goal of this exercise is to introduce errors, custom error types and how they are used in Julia. This should be taught through a refactoring exercise, where all errors are thrown with error(). The student should replace those with their own custom error type, and existing errors, e.g. DomainError, where appropriate.
Learning objectives
- Learn that it's better to avoid errors rather than relying on catching them [ref. Style guide], and that try-catch should usually not be used for control flow (and why) (and perhaps that some Julia devs don't consider errors part of an API, therefore changing them may be considered non-breaking)
- Learn how to define their own errors
- Why
error()should often be avoided - Learn about the existance of (some) standard error types
Concepts
-
errors -
error-handling/try-catch
Prerequisites
-
composite-types - Whatever else is required to understand the code they're refactoring. Try to stick to basic concepts.
Resources to refer to
- https://docs.julialang.org/en/v1/manual/control-flow/#Exception-Handling
- https://discourse.julialang.org/t/please-stop-using-error-and-errorexception-in-packages-and-base/12096
Implementing
The tests should test the following:
- Whether the refactoring broke the functionality
- Whether the student implemented new error types. These could be marked as
@test_broken.
Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue.