From dcbf5e7533dfaf3f7903b21e159243e63910ae67 Mon Sep 17 00:00:00 2001 From: Myle Ott Date: Tue, 26 Dec 2017 12:53:14 -0800 Subject: [PATCH] Raise FileNotFoundError if dictionary files don't exist --- fairseq/dictionary.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fairseq/dictionary.py b/fairseq/dictionary.py index e85fb9fe99..1f597431e6 100644 --- a/fairseq/dictionary.py +++ b/fairseq/dictionary.py @@ -113,6 +113,8 @@ def load(f): try: with open(f, 'r', encoding='utf-8') as fd: return Dictionary.load(fd) + except FileNotFoundError as fnfe: + raise fnfe except: raise Exception("Incorrect encoding detected in {}, please " "rebuild the dataset".format(f))