aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Bobrov <breton@cynicmansion.ru>2016-02-23 03:57:00 +0300
committerBoris Bobrov <breton@cynicmansion.ru>2016-02-23 03:57:00 +0300
commit7dcdc2dcc679560cbd85ae704ee9d27b94b6a85a (patch)
tree2549c48e72c6646ca6a71a529363f97ae0845b88
parent1fe6f5d6d78c4e6f55820614b54be6562265ffa3 (diff)
downloadmediagoblin-7dcdc2dcc679560cbd85ae704ee9d27b94b6a85a.tar.lz
mediagoblin-7dcdc2dcc679560cbd85ae704ee9d27b94b6a85a.tar.xz
mediagoblin-7dcdc2dcc679560cbd85ae704ee9d27b94b6a85a.zip
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.
-rw-r--r--mediagoblin/db/mixin.py12
1 files changed, 11 insertions, 1 deletions
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"""