The errors should have suitable exception classes. Right now we raise `Exception` in many parts of the code. This should be fixed.