I am working on a calibre Conversion Output plugin and have come across something that I don't understand so I am asking about it here.
Unfortunately, the plugin is expected to fail to convert some books and I want to notify the user of the reason why when this occurs. To do this I am raising a ConversionUserFeedBack exception to provide the error message. I used this test code to always simulate a conversion error:
When I start a conversion that uses this output plugin this works properly for most books and pops up a dialog box with a title of Conversion failed and a message of test. The end of the job log shows the exception I raised as expected:
However, this does not work for a small subset of books and I can't figure out why. For these books it consistently fails to give the expected error dialog. Instead it pops up a generic conversion error dialog. Looking at the end of the conversion job log for those book I see the following:
Note that the exception shows as ConversionUserFeedBack instead of calibre.ebooks.conversion.ConversionUserFeedBack. This causes the problem since the code in calibre/gui2/ui.py is looking for only the longer string.
I cannot figure out why the exception is sometimes reported differently in the log. Any help would be appreciated.
Unfortunately, the plugin is expected to fail to convert some books and I want to notify the user of the reason why when this occurs. To do this I am raising a ConversionUserFeedBack exception to provide the error message. I used this test code to always simulate a conversion error:
Code:
def convert(self, oeb_book, output, input_plugin, opts, log):
import calibre.ebooks.conversion
raise calibre.ebooks.conversion.ConversionUserFeedBack("Conversion failed", "test", level="error")
Code:
Python function terminated unexpectedly
{"title": "Conversion failed", "msg": "test", "det_msg": "", "level": "error"} (Error Code: 1)
Traceback (most recent call last):
File "site.py", line 132, in main
File "site.py", line 109, in run_entry_point
File "site-packages\calibre\utils\ipc\worker.py", line 190, in main
File "site-packages\calibre\gui2\convert\gui_conversion.py", line 31, in gui_convert_override
File "site-packages\calibre\gui2\convert\gui_conversion.py", line 25, in gui_convert
File "site-packages\calibre\ebooks\conversion\plumber.py", line 1219, in run
File "calibre_plugins.kfx_output.__init__", line 49, in convert
calibre.ebooks.conversion.ConversionUserFeedBack: {"title": "Conversion failed", "msg": "test", "det_msg": "", "level": "error"}
Code:
[Python function terminated unexpectedly
{"title": "Conversion failed", "det_msg": "", "level": "error", "msg": "test"} (Error Code: 1)
Traceback (most recent call last):
File "site.py", line 132, in main
File "site.py", line 109, in run_entry_point
File "site-packages\calibre\utils\ipc\worker.py", line 190, in main
File "site-packages\calibre\gui2\convert\gui_conversion.py", line 31, in gui_convert_override
File "site-packages\calibre\gui2\convert\gui_conversion.py", line 25, in gui_convert
File "site-packages\calibre\ebooks\conversion\plumber.py", line 1219, in run
File "calibre_plugins.kfx_output.__init__", line 49, in convert
ConversionUserFeedBack: {"title": "Conversion failed", "det_msg": "", "level": "error", "msg": "test"}
I cannot figure out why the exception is sometimes reported differently in the log. Any help would be appreciated.