Closed BethanyG closed 2 years ago
This issue has been automatically marked as abandoned 🏚
because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I can only hope to abandon this. Nice try, gitbot, but I think this needs to stay open. 😞
Related website issue that might prevent these from showing right away: https://github.com/exercism/exercism/issues/6063. Should be fixed soon (probably before these are all done).
When we transitioned to the current version of exercism, we removed the generic "raising exceptions" notices from all the exercise READMEs. We felt they were adding confusion and leading students to insert error raising and handling in places where they should not have been inserting it.
For the Python track, we were (and are!) planning
error handling
concept exercises to help students learn how to raise and handle errors properly in their code.But those exercises are still in process, and we have 42 practice exercises that test for error handling in one way or another.
37 of these include
JinJa2
test generation templates.As a stopgap while we create the
error handling
concept exercises, we need to create practice exercise.docs/instructions.append.md
files for the42
exercises that add back a blurb about how to raise an exception. The original vs proposed language for theinstructions.append.md
is at the bottom, but is open to any edits that make sense and help student understanding.For the 37
JinJa2
exercises, we will need to modify the test generation templates to test for a meaningful exception message, and not just the presence of any exception. We'll then need to regenerate those test files.For the 5 exercises that remain, we will need to hand-edit the test files as opposed to editing a generation template.
Recommend that a PR for ONE exercise be done as a first pass to make sure the changes do indeed makes sense, then the remainder of them can be done.
These are the 42 practice exercises in question:
PR 2685
PR 2691
PR 2692
error-handling | test fileExercise has been depreciated.PR 2715
hexadecimal | test fileExercise has been depreciated.PR 2716
nucleotide-count | test fileExercise has been depreciated.octal | test fileExercise has been deprciated.PR 2725
PR 2727
rational-numbers | test file | template fileactually, no error cases here.robot-simulator | test file | template fileNo error cases currently. Consider adding some later.roman-numerals | test file | template fileDoesn't have error cases either. Maybe we should consider adding some.run-length-encoding | test file | template fileNo error cases.PR 2734
The original and proposed new
error handling
messages are below.[ORIGINAL]
Exception messages
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include a message.
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of raise Exception, you should write:
raise Exception("Meaningful message indicating the source of the error")
[Suggested Changes]
Exception messages
Sometimes it is necessary to raise an exception. When you do this, you should always include a meaningful error message to indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. For situations where you know that the error source will be a certain type, you can choose to rase one of the built in error types, but should still include a meaningful message.
This particular exercise requires that you use the raise statement to "throw" an
exception
. The tests will only pass if you bothraise
theexception
and include a message with it.To raise an
exception
with a message, write the message as an argument to theexception
type: