Refactored file error code