mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 23:42:12 +02:00
Fix #120: Better error handling during file import
This commit is contained in:
parent
f1cf250e29
commit
e99d757b57
3 changed files with 36 additions and 15 deletions
|
@ -121,7 +121,13 @@ class Metadata(object):
|
|||
|
||||
def __init__(self, path):
|
||||
self._file = mutagen.File(path)
|
||||
self._conf = CONF[self.get_file_type(self._file)]
|
||||
if self._file is None:
|
||||
raise ValueError('Cannot parse metadata from {}'.format(path))
|
||||
ft = self.get_file_type(self._file)
|
||||
try:
|
||||
self._conf = CONF[ft]
|
||||
except KeyError:
|
||||
raise ValueError('Unsupported format {}'.format(ft))
|
||||
|
||||
def get_file_type(self, f):
|
||||
return f.__class__.__name__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue