Skip to content

Commit

Permalink
Merge pull request #1022 from googlefonts/put-glyph-exceptions
Browse files Browse the repository at this point in the history
putGlyph no longer returns an optional error message
  • Loading branch information
justvanrossum authored Dec 13, 2023
2 parents cb9db4d + ec77c5a commit b5fb3b0
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions src/fontra/core/fonthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ async def processWrites(self) -> None:
self._writingInProgressEvent.set()

async def _processWritesOneCycle(self) -> None:
writeFunc: Callable[
[], Awaitable[None]
] # inferencing with partial() goes wrong
while self._dataScheduledForWriting:
writeKey, (writeFunc, connection) = popFirstItem(
self._dataScheduledForWriting
)
reloadPattern = _writeKeyToPattern(writeKey)
logger.info(f"write {writeKey} to backend")
try:
errorMessage = await writeFunc()
await writeFunc()
except Exception as e:
logger.error("exception while writing data: %r", e)
traceback.print_exc()
Expand All @@ -132,25 +135,6 @@ async def _processWritesOneCycle(self) -> None:
else:
# No connection to inform, let's error
raise
else:
if errorMessage:
messageDetail = f"The edit has been reverted.\n\n{errorMessage}"
try:
await self.reloadData(reloadPattern)
except Exception as e:
messageDetail = (
f"{errorMessage}\n\n"
"The edit could not be reverted due to an additional error."
f"\n\n{e!r}"
)
if connection is not None:
await connection.proxy.messageFromServer(
"The data could not be saved.",
messageDetail,
)
else:
# This ideally can't happen
assert False, errorMessage
await asyncio.sleep(0)

@asynccontextmanager
Expand Down Expand Up @@ -360,7 +344,9 @@ async def _prepareRootObject(self, change):
async def _updateLocalData(
self, rootKeys, rootObject, sourceConnection, writeToBackEnd
) -> None:
writeFunc: Callable[[], Awaitable] # inferencing with partial() goes wrong
writeFunc: Callable[
[], Awaitable[None]
] # inferencing with partial() goes wrong
for rootKey in rootKeys + sorted(rootObject._assignedAttributeNames):
if rootKey == "glyphs":
glyphSet = rootObject.glyphs
Expand Down

0 comments on commit b5fb3b0

Please sign in to comment.