Add exception classes and functions

Add two exception classes for fatal and minor errors.
Add a function which builds an error message.
Add functions which throw exceptions with this messages.