From abcdf07ef446310e67285b0c1eef633b53e21dbd Mon Sep 17 00:00:00 2001
From: jvoisin <julien.voisin@dustri.org>
Date: Thu, 7 Sep 2023 16:31:34 +0200
Subject: [PATCH] Properly handle a cairo exception

---
 libmat2/pdf.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libmat2/pdf.py b/libmat2/pdf.py
index 8c3055f..ca94067 100644
--- a/libmat2/pdf.py
+++ b/libmat2/pdf.py
@@ -36,7 +36,10 @@ class PDFParser(abstract.AbstractParser):
 
     def remove_all(self) -> bool:
         if self.lightweight_cleaning is True:
-            return self.__remove_all_lightweight()
+            try:
+                return self.__remove_all_lightweight()
+            except cairo.Error as e:
+                raise RuntimeError(e)
         return self.__remove_all_thorough()
 
     def __remove_all_lightweight(self) -> bool:
-- 
GitLab