template method is updated for error code