Refactor error reporting API.