replaygain: More descriptive backend errors

This avoids a bare `except:` to catch specific errors and give better messages
when they fail. Should provide more insight to this trouble:
https://groups.google.com/d/msg/beets-users/6d-TOg0SuPY/iL39tmo3rqUJ

Also related to #874.

Feedback from @yevgenybezman or others more familiar with the backend would be
welcome.
This commit is contained in:
Adrian Sampson 2014-10-09 12:26:53 -07:00
parent 983aac287b
commit c5293df963

View file

@ -273,20 +273,26 @@ class GStreamerBackend(object):
try:
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst, GLib
# Calling GObject.threads_init() is not needed for
# PyGObject 3.10.2+
with warnings.catch_warnings():
warnings.simplefilter("ignore")
GObject.threads_init()
Gst.init([sys.argv[0]])
except:
except ImportError:
raise FatalReplayGainError(
"Failed to load GStreamer; check that python-gi is installed"
"Failed to load GStreamer: python-gi not found"
)
try:
gi.require_version('Gst', '1.0')
except ValueError as e:
raise FatalReplayGainError(
"Failed to load GStreamer 1.0: {0}".format(e)
)
from gi.repository import GObject, Gst, GLib
# Calling GObject.threads_init() is not needed for
# PyGObject 3.10.2+
with warnings.catch_warnings():
warnings.simplefilter("ignore")
GObject.threads_init()
Gst.init([sys.argv[0]])
self.GObject = GObject
self.GLib = GLib
self.Gst = Gst
@ -498,7 +504,7 @@ class ReplayGainPlugin(BeetsPlugin):
)
except (ReplayGainError, FatalReplayGainError) as e:
raise ui.UserError(
'An error occurred in backend initialization: {0}'.format(e)
'replaygain initialization failed: {0}'.format(e)
)
def track_requires_gain(self, item):