Skip to content

Exeptions

Theo edited this page Jul 6, 2020 · 3 revisions

When the program encounters a fatal error, it will throw an exception, 😱 at you and stop running. A traceback will be output to the program's UI (the black-and-white command-line-looking thing). An exception traceback looks like this:

Traceback (most recent call last):
  File "cis_win-0.1.0.py", line 99, in <module>
__main__.ConfigError: Configuration file generated. Please fill.
[10504] Failed to execute script cis_win-0.1.0

In this case, the fix is easy: the exception telles everything. The program has generated the config file and you need to fill it.

Exception Anatomy 101

Using above writen example:

__main__.ConfigError: Configuration file generated. Please fill.
Exception type      : detail string
  • The exception type specifies what exception was thrown. It can be used for exception handeling.
  • The deail string tells what went wrong, and sometimes how to fix it. This is the important part for you.

Python Exceptions

As this is a python program, most (unintended) exceptions will be standard built-in python exception.

Intendely raised built-in exceptons:

  • TypeError: A TypeError is an exception thrown when a the expected type is not correct.

Custom Exceptions

There are 3 not built-in exceptions:

  • ImplementationError: This exception is raised when a snipplet of the program is called but not implemented yet.
  • AdminError: This error is called when you run the program without administrator rights. They are needed because group policies are protected objects.
  • ConfigError: This exception is thrown when the config file is not correct.

Unhandled Exceptions

It is always possible that the program screws up or that it behaves unintentionally. In that case, you will get an exception traceback which is a bit less not-programmer understandable. If you think that this is unintentional or should be fixed, please look at existing issue to find more information, if it is currently beeing worked on or if there is a fix. If there is no open issue helping you, open a new issue. I will be glad to help!

Clone this wiki locally