Fix bad indentation
Change error factory methods to take classes as parameters
Fix error code names
Change serialisation format to JSON-like
Fix input parameter type to more strict