Improve error reporting in service

Add a way to add error code to errors