diff options
| author | 2021-04-09 23:12:54 +0530 | |
|---|---|---|
| committer | 2021-04-09 23:12:54 +0530 | |
| commit | 4675123f4e3e5a23623a2f2b062f754370c42673 (patch) | |
| tree | d104866cc6337a0f645c286999d5130e67065eb5 /bot/exts/evergreen/latex.py | |
| parent | remove redundant use of functools.partial (diff) | |
exclude non error-causing lines from try-except
Diffstat (limited to 'bot/exts/evergreen/latex.py')
| -rw-r--r-- | bot/exts/evergreen/latex.py | 11 | 
1 files changed, 5 insertions, 6 deletions
diff --git a/bot/exts/evergreen/latex.py b/bot/exts/evergreen/latex.py index a8ed56fb..7cc3432f 100644 --- a/bot/exts/evergreen/latex.py +++ b/bot/exts/evergreen/latex.py @@ -36,18 +36,17 @@ class Latex(commands.Cog):      def _render(text: str) -> BytesIO:          """Return the rendered image if latex compiles without errors, otherwise raise a BadArgument Exception."""          fig = plt.figure() +        rendered_image = BytesIO() +        fig.text(0, 1, text, horizontalalignment="left", verticalalignment="top")          try: -            fig.text(0, 1, text, horizontalalignment="left", verticalalignment="top") - -            rendered_image = BytesIO()              plt.savefig(rendered_image, bbox_inches="tight", dpi=600) -            rendered_image.seek(0) -            return rendered_image -          except ValueError as e:              raise commands.BadArgument(str(e)) +        rendered_image.seek(0) +        return rendered_image +      @staticmethod      def _prepare_input(text: str) -> str:          text = text.replace(r"\\", "$\n$")  # matplotlib uses \n for newlines, not \\  |