Merge pull request #1186 from anthrotype/included-not-found
feaLib: add IncludedFeaNotFound error
This commit is contained in:
commit
ea5980b6ba
@ -14,3 +14,7 @@ class FeatureLibError(Exception):
|
|||||||
return "%s:%d:%d: %s" % (path, line, column, message)
|
return "%s:%d:%d: %s" % (path, line, column, message)
|
||||||
else:
|
else:
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
class IncludedFeaNotFound(FeatureLibError):
|
||||||
|
pass
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from __future__ import print_function, division, absolute_import
|
from __future__ import print_function, division, absolute_import
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from fontTools.misc.py23 import *
|
from fontTools.misc.py23 import *
|
||||||
from fontTools.feaLib.error import FeatureLibError
|
from fontTools.feaLib.error import FeatureLibError, IncludedFeaNotFound
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -231,7 +231,11 @@ class IncludingLexer(object):
|
|||||||
try:
|
try:
|
||||||
fileobj = open(filename, "r", encoding="utf-8")
|
fileobj = open(filename, "r", encoding="utf-8")
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
raise FeatureLibError(str(err), location)
|
# FileNotFoundError does not exist on Python < 3.3
|
||||||
|
import errno
|
||||||
|
if err.errno == errno.ENOENT:
|
||||||
|
raise IncludedFeaNotFound(str(err), location)
|
||||||
|
raise # pragma: no cover
|
||||||
data = fileobj.read()
|
data = fileobj.read()
|
||||||
filename = fileobj.name if hasattr(fileobj, "name") else "<features>"
|
filename = fileobj.name if hasattr(fileobj, "name") else "<features>"
|
||||||
if closing:
|
if closing:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user