1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +00:00

Improved error reporting

This commit is contained in:
Paweł Jastrzębski
2016-11-26 17:59:40 +01:00
parent 9ad161489f
commit 30b8770e34
4 changed files with 20 additions and 12 deletions

View File

@@ -317,10 +317,15 @@ class WorkerThread(QtCore.QThread):
GUI.progress.content = ''
self.errors = True
_, _, traceback = sys.exc_info()
if len(err.args) == 1:
MW.showDialog.emit("Error during conversion %s:\n\n%s\n\nTraceback:\n%s"
% (jobargv[-1], str(err), sanitizeTrace(traceback)), 'error')
else:
MW.showDialog.emit("Error during conversion %s:\n\n%s\n\nTraceback:\n%s"
% (jobargv[-1], str(err.args[0]), err.args[1]), 'error')
GUI.sentry.extra_context({'realTraceback': err.args[1]})
if ' is corrupted.' not in str(err):
GUI.sentry.captureException()
MW.showDialog.emit("Error during conversion %s:\n\n%s\n\nTraceback:\n%s"
% (jobargv[-1], str(err), sanitizeTrace(traceback)), 'error')
MW.addMessage.emit('Error during conversion! Please consult '
'<a href="https://github.com/ciromattia/kcc/wiki/Error-messages">wiki</a> '
'for more details.', 'error', False)

View File

@@ -46,7 +46,7 @@ try:
from scandir import walk
except ImportError:
walk = os.walk
from .shared import md5Checksum, getImageFileName, walkSort, walkLevel, saferReplace, saferRemove
from .shared import md5Checksum, getImageFileName, walkSort, walkLevel, saferReplace, saferRemove, sanitizeTrace
from . import comic2panel
from . import image
from . import cbxarchive
@@ -482,7 +482,7 @@ def imgDirectoryProcessing(path):
raise UserWarning("Conversion interrupted.")
if len(workerOutput) > 0:
rmtree(os.path.join(path, '..', '..'), True)
raise RuntimeError("One of workers crashed. Cause: " + workerOutput[0])
raise RuntimeError("One of workers crashed. Cause: " + workerOutput[0][0], workerOutput[0][1])
for file in options.imgPurgeIndex:
if os.path.isfile(file):
saferRemove(file)
@@ -492,7 +492,7 @@ def imgDirectoryProcessing(path):
def imgFileProcessingTick(output):
if isinstance(output, str):
if isinstance(output, tuple):
workerOutput.append(output)
workerPool.terminate()
else:
@@ -526,7 +526,7 @@ def imgFileProcessing(work):
output.append(img.saveToDir())
return output
except Exception:
return str(sys.exc_info()[:2])
return str(sys.exc_info()[1]), sanitizeTrace(sys.exc_info()[2])
def getWorkFolder(afile):

View File

@@ -24,7 +24,7 @@ from shutil import rmtree, copytree, move
from optparse import OptionParser, OptionGroup
from multiprocessing import Pool
from PIL import Image, ImageStat, ImageOps
from .shared import getImageFileName, walkLevel, walkSort, saferRemove
from .shared import getImageFileName, walkLevel, walkSort, saferRemove, sanitizeTrace
try:
from PyQt5 import QtCore
except ImportError:
@@ -81,7 +81,7 @@ def mergeDirectory(work):
savePath = os.path.split(imagesValid[0])
result.save(os.path.join(savePath[0], os.path.splitext(savePath[1])[0] + '.png'), 'PNG')
except Exception:
return str(sys.exc_info()[1])
return str(sys.exc_info()[1]), sanitizeTrace(sys.exc_info()[2])
def sanitizePanelSize(panel, opt):
@@ -205,7 +205,7 @@ def splitImage(work):
pageNumber += 1
saferRemove(filePath)
except Exception:
return str(sys.exc_info()[1])
return str(sys.exc_info()[1]), sanitizeTrace(sys.exc_info()[2])
def main(argv=None, qtGUI=None):
@@ -267,7 +267,7 @@ def main(argv=None, qtGUI=None):
raise UserWarning("Conversion interrupted.")
if len(mergeWorkerOutput) > 0:
rmtree(options.targetDir, True)
raise RuntimeError("One of workers crashed. Cause: " + mergeWorkerOutput[0])
raise RuntimeError("One of workers crashed. Cause: " + mergeWorkerOutput[0][0], mergeWorkerOutput[0][1])
print("Splitting images...")
for root, dirs, files in walk(options.targetDir, False):
for name in files:
@@ -290,7 +290,7 @@ def main(argv=None, qtGUI=None):
raise UserWarning("Conversion interrupted.")
if len(splitWorkerOutput) > 0:
rmtree(options.targetDir, True)
raise RuntimeError("One of workers crashed. Cause: " + splitWorkerOutput[0])
raise RuntimeError("One of workers crashed. Cause: " + splitWorkerOutput[0][0], splitWorkerOutput[0][1])
if options.inPlace:
rmtree(options.sourceDir)
move(options.targetDir, options.sourceDir)

View File

@@ -144,7 +144,10 @@ def removeFromZIP(zipfname, *filenames):
def sanitizeTrace(traceback):
return ''.join(format_tb(traceback))\
.replace('C:\\Users\\Pawel\\Documents\\Projekty\\KCC\\', '') \
.replace('C:/Users/Pawel/Documents/Projekty/KCC/', '')\
.replace('C:/Python35/', '')\
.replace('c:/python35/', '')\
.replace('C:\\Users\\Pawel\\Documents\\Projekty\\KCC\\', '')\
.replace('C:\\Python35\\', '')\
.replace('c:\\python35\\', '')