how to return an error code