Better OTL builder errors (#3286)
* Raise a sensible error for keyerror * Try harder to find error locations * Chain exception
This commit is contained in:
parent
05dc231072
commit
c5295d2f16
@ -844,10 +844,15 @@ class Builder(object):
|
||||
feature=None,
|
||||
)
|
||||
lookups.append(lookup)
|
||||
try:
|
||||
otLookups = [l.build() for l in lookups]
|
||||
except OpenTypeLibError as e:
|
||||
raise FeatureLibError(str(e), e.location) from e
|
||||
otLookups = []
|
||||
for l in lookups:
|
||||
try:
|
||||
otLookups.append(l.build())
|
||||
except OpenTypeLibError as e:
|
||||
raise FeatureLibError(str(e), e.location) from e
|
||||
except Exception as e:
|
||||
location = self.lookup_locations[tag][str(l.lookup_index)].location
|
||||
raise FeatureLibError(str(e), location) from e
|
||||
return otLookups
|
||||
|
||||
def makeTable(self, tag):
|
||||
|
@ -55,7 +55,11 @@ def buildCoverage(glyphs, glyphMap):
|
||||
if not glyphs:
|
||||
return None
|
||||
self = ot.Coverage()
|
||||
self.glyphs = sorted(set(glyphs), key=glyphMap.__getitem__)
|
||||
try:
|
||||
self.glyphs = sorted(set(glyphs), key=glyphMap.__getitem__)
|
||||
except KeyError as e:
|
||||
raise ValueError(f"Could not find glyph {e} in font") from e
|
||||
|
||||
return self
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user