Improve the error handling
Created by: Leo Schwarz
Created by: leoschwarz
It was done rather sloppy, it will definitely need a nicer API before the 1.0 release. Maybe a lot of the error variants should be hidden, but it should be made sure that we will be able to obtain relevant debug diagnostics when required.