diff --git a/Lib/fontTools/feaLib/error.py b/Lib/fontTools/feaLib/error.py index 82a7dec5a..66c6c6eae 100644 --- a/Lib/fontTools/feaLib/error.py +++ b/Lib/fontTools/feaLib/error.py @@ -9,10 +9,18 @@ class FeatureLibError(Exception): message = Exception.__str__(self) if self.location: path, line, column = self.location - return "%s:%d:%d: %s" % (path, line, column, message) + return f"{path}:{line}:{column}: {message}" else: return message class IncludedFeaNotFound(FeatureLibError): - pass + def __str__(self): + assert self.location is not None + + message = ( + "The following feature file should be included but cannot be found: " + f"{Exception.__str__(self)}" + ) + path, line, column = self.location + return f"{path}:{line}:{column}: {message}" diff --git a/Tests/feaLib/lexer_test.py b/Tests/feaLib/lexer_test.py index fa3f0ea57..3837801f5 100644 --- a/Tests/feaLib/lexer_test.py +++ b/Tests/feaLib/lexer_test.py @@ -178,7 +178,9 @@ class IncludingLexerTest(unittest.TestCase): def test_include_missing_file(self): lexer = IncludingLexer(self.getpath("include/includemissingfile.fea")) self.assertRaisesRegex(IncludedFeaNotFound, - "includemissingfile.fea:1:8: missingfile.fea", + "includemissingfile.fea:1:8: The following feature file " + "should be included but cannot be found: " + "missingfile.fea", lambda: list(lexer)) def test_featurefilepath_None(self):