diff --git a/latex.py b/latex.py
index 8ccf572..29c126d 100644
--- a/latex.py
+++ b/latex.py
@@ -24,9 +24,9 @@ def render(user: str, source: str, png: bool = True) -> str:
tmp.close()
# Parse our templated file thru' LaTeX and dvipng.
# TODO: Allow arbitrary DPI and foreground color.
- ret = subprocess.run(["latex", "-halt-on-error", tmp.name], cwd="/tmp").returncode
- if ret != 0:
- raise FileNotFoundError("DVI couldn't be built.")
+ ret = subprocess.run(["latex", "-halt-on-error", tmp.name], cwd="/tmp", capture_output=True)
+ if ret.returncode != 0:
+ raise FileNotFoundError(ret.stdout.decode())
if png:
print("PNG")
diff --git a/main.py b/main.py
index c940ab7..1b042e4 100644
--- a/main.py
+++ b/main.py
@@ -42,16 +42,23 @@ async def msg_cb(room: MatrixRoom, event: RoomMessageText) -> None:
try:
filename = latex.render("", event.body)
await send_png(room, filename)
- except (FileNotFoundError, OSError):
+ except FileNotFoundError as e:
content = {
"msgtype": "m.text",
- "body": "Couldn't parse LaTeX correctly."
+ "body": f"Couldn't parse LaTeX correctly.\n```{e.args[0]}\n```",
+ "formatted_body": f"Couldn't parse LaTeX correctly.
{e.args[0]}
",
}
+
await client.room_send(room.room_id, message_type="m.room.message", content=content)
+ except OSError:
+ content = {
+ "msgtype": "m.text",
+ "body": "???",
+ "formatted_body": "???"
+ }
+ await client.room_send(room.room_id, message_type="m.room.message", content=content)
# Our file callback.
-
-
async def file_cb(room: MatrixRoom, event: RoomMessageFile) -> None:
url = event.url
filename = event.body