Skip to content

Commit

Permalink
Create misc.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtournier authored Nov 21, 2024
1 parent 435240e commit 6333356
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
layout: presentation
title: "Miscellaneous slides"
---

# Error handling

The previous example is a simple way to handle errors.
- we'll learn a better way when we cover *exceptions* later in the course

--

Some general rules about error handling:

- If your code is making assumptions about its inputs, check them!
- for example, if your code assumes a parameter is positive, check and alert the user if this is not the case (and exit if appropriate)
- *this will save you time later on!*

--

- If you can reasonably handle the error, do so, but warn the user about it

--

- Most of the time, the error will be *fatal* (not recoverable), in which case your program should *not* proceed
- issue an informative message about the problem, and exit with a non-zero exit code

--

- try to detect errors as early as possible
- for example: don't start a long batch of processing without first checking that you can create the output file

0 comments on commit 6333356

Please sign in to comment.