add serialised error enum and rc enum
switch serialiser logic to switch statement for type niceness