Skip to content
Permalink
Browse files

DBManager: replace the deprecated Exception.message attribute

  • Loading branch information
brushtyler committed May 27, 2013
1 parent f5aef0f commit 5d8964a4754cde8371c1836765cd546e7befa905
Showing with 11 additions and 6 deletions.
  1. +8 −3 python/plugins/db_manager/db_plugins/plugin.py
  2. +3 −3 python/plugins/db_manager/dlg_db_error.py
@@ -29,16 +29,21 @@
class BaseError(Exception):
"""Base class for exceptions in the plugin."""
def __init__(self, e):
msg = e if isinstance(e, (str,unicode,QString)) else e.message
if isinstance(e, Exception):
msg = e.args[0] if len(e.args) > 0 else ''
else:
msg = e

try:
msg = unicode( msg )
except UnicodeDecodeError:
msg = unicode( msg, 'utf-8' )

self.msg = msg
Exception.__init__(self, msg)

def __unicode__(self):
return self.message
return self.msg

def __str__(self):
return unicode(self).encode('utf-8')
@@ -55,7 +60,7 @@ def __init__(self, e, query=None):
self.query = unicode( query ) if query != None else None

def __unicode__(self):
if self.query == None:
if self.query is None:
return BaseError.__unicode__(self)

msg = u"Error:\n%s" % BaseError.__unicode__(self)
@@ -36,10 +36,10 @@ def __init__(self, e, parent=None):
def sanitize(txt):
return "" if txt == None else "<pre>" + txt.replace('<','&lt;') + "</pre>"

if isinstance(e, DbError) and hasattr(e, 'query'):
self.setQueryMessage( sanitize(e.message), sanitize(e.query) )
if isinstance(e, DbError):
self.setQueryMessage( sanitize(e.msg), sanitize(e.query) )
else:
self.setMessage( sanitize(e.message) )
self.setMessage( sanitize(e.msg) )

def setMessage(self, msg):
self.txtErrorMsg.setHtml(msg)

0 comments on commit 5d8964a

Please sign in to comment.
You can’t perform that action at this time.