Blob Blame History Raw
From 03ddf5bd3ad6e7f76a05ae6dc04ec8ec16c14cb1 Mon Sep 17 00:00:00 2001
From: Kovid Goyal <kovid@kovidgoyal.net>
Date: Wed, 24 Jul 2019 19:51:33 +0530
Subject: [PATCH 13/71] Get more information from podofo exceptions

---
 src/calibre/utils/podofo/utils.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/calibre/utils/podofo/utils.cpp b/src/calibre/utils/podofo/utils.cpp
index dd934b7f3d..a8755278cb 100644
--- a/src/calibre/utils/podofo/utils.cpp
+++ b/src/calibre/utils/podofo/utils.cpp
@@ -9,10 +9,16 @@
 
 using namespace pdf;
 
-void pdf::podofo_set_exception(const PdfError &err) {
+void
+pdf::podofo_set_exception(const PdfError &err) {
     const char *msg = PdfError::ErrorMessage(err.GetError());
     if (msg == NULL) msg = err.what();
-    PyErr_SetString(Error, msg);
+    std::stringstream stream;
+    stream << msg << "\n";
+    for (auto &info : err.GetCallstack()) {
+        stream << "File: " << info.GetFilename() << "Line: " << info.GetLine() << " " << info.GetInformation() << "\n";
+    }
+    PyErr_SetString(Error, stream.str().c_str());
 }
 
 PyObject *