Software-Engineering
# What is an Error?
There are 2 distinguishable kinds of errors:
- syntax errors
errors detected by compiler
arrow - points at earliest point, where error was detected
- exceptions
errors detected during execution
last line indicated what happened
exceptions come in different tyes
types in this example: ZeroDivisionError
, NameError
, TypeError
# Handling Exceptions
it’s possible to write programms that handle selected exceptions
# try except
try
tries something - if it does not work properly:
except
clause with specific type is executed
Example - wants user to input a valid integer (user can interrupt program - ctrl-c)
# raise
allows the programmer to force a specified exception to occur
Example - raise a custom type exception
# User-defined Exceptions
Exceptions should be derived from Exception
class, either directly/indirectly
An Exception should end with the word “Error”