From: Boris Bobrov Date: Tue, 23 Feb 2016 00:57:00 +0000 (+0300) Subject: Catch import error when text is used as a reason instead of path X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7dcdc2dcc679560cbd85ae704ee9d27b94b6a85a;p=mediagoblin.git Catch import error when text is used as a reason instead of path fail_error was used in import, but due to some changes text could appear there and it caused an error. There is little sense now to remove these text messages because they are probably in databases already, so just ignore import errors. --- diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index 083617d3..c8c5f95c 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -330,7 +330,17 @@ class MediaEntryMixin(GenerateSlugMixin, GeneratePublicIDMixin): Get the exception that's appropriate for this error """ if self.fail_error: - return common.import_component(self.fail_error) + try: + return common.import_component(self.fail_error) + except ImportError: + # TODO(breton): fail_error should give some hint about why it + # failed. fail_error is used as a path to import(). + # Unfortunately, I didn't know about that and put general error + # message there. Maybe it's for the best, because for admin, + # we could show even some raw python things. Anyway, this + # should be properly resolved. Now we are in a freeze, that's + # why I simply catch ImportError. + return self.fail_error def get_license_data(self): """Return license dict for requested license"""