mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-14 19:53:59 +00:00
PICARD-2662: display a more explicit message on Mutagen errors (#2245)
* PICARD-2662: display a more explicit message on Mutagen errors * MUTAGEN -> PARSER
This commit is contained in:
@@ -56,6 +56,8 @@ import re
|
||||
import shutil
|
||||
import time
|
||||
|
||||
from mutagen._util import MutagenError
|
||||
|
||||
from PyQt5 import QtCore
|
||||
|
||||
from picard import (
|
||||
@@ -106,6 +108,7 @@ class FileErrorType(Enum):
|
||||
UNKNOWN = auto()
|
||||
NOTFOUND = auto()
|
||||
NOACCESS = auto()
|
||||
PARSER = auto()
|
||||
|
||||
|
||||
class File(QtCore.QObject, Item):
|
||||
@@ -205,13 +208,16 @@ class File(QtCore.QObject, Item):
|
||||
|
||||
def _set_error(self, error):
|
||||
self.state = File.ERROR
|
||||
self.error_append(str(error))
|
||||
if any_exception_isinstance(error, FileNotFoundError):
|
||||
if any_exception_isinstance(error, MutagenError):
|
||||
self.error_type = FileErrorType.PARSER
|
||||
self.error_append(_('The file failed to parse, either the file is damaged or has an unsupported file format.'))
|
||||
elif any_exception_isinstance(error, FileNotFoundError):
|
||||
self.error_type = FileErrorType.NOTFOUND
|
||||
elif any_exception_isinstance(error, PermissionError):
|
||||
self.error_type = FileErrorType.NOACCESS
|
||||
else:
|
||||
self.error_type = FileErrorType.UNKNOWN
|
||||
self.error_append(str(error))
|
||||
|
||||
def load(self, callback):
|
||||
thread.run_task(
|
||||
|
||||
Reference in New Issue
Block a user