Skip to content

Commit bc0b8f8

Browse files
committed
fix: report pylatex compiler errors too
1 parent ef9ad52 commit bc0b8f8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

bmt_discord_bot/cogs/math.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from discord.ext import commands
1010
from jishaku.functools import executor_function
1111
from pylatex import Document, NoEscape, Package
12+
import pylatex
1213
from PIL import Image, ImageOps
1314
import pymupdf
1415
from abc import ABC, abstractmethod
@@ -75,6 +76,8 @@ def compile_source(self, output_path: Path, source: str):
7576
document.preamble.append(Package("amsmath"))
7677
try:
7778
document.generate_pdf(compiler="texfot", compiler_args=["--quiet", "pdflatex"])
79+
except pylatex.errors.CompilerError as e:
80+
raise CompileError(e)
7881
except subprocess.CalledProcessError as e:
7982
raise CompileError(e.output.decode())
8083

@@ -92,7 +95,7 @@ def compile_source(self, output_path: Path, source: str):
9295
try:
9396
typst.compile(source_bytes, output_path, format="pdf")
9497
except RuntimeError as e:
95-
raise CompileError(str(e))
98+
raise CompileError(e)
9699

97100

98101
class MathView(discord.ui.View):

0 commit comments

Comments
 (0)