Revision: 6607
Author: nicdumz
Date: 2009-04-15 08:28:21 +0000 (Wed, 15 Apr 2009)
Log Message:
-----------
Adding a __unicode__ method for pywikibot.Error
Modified Paths:
--------------
branches/rewrite/pywikibot/exceptions.py
Modified: branches/rewrite/pywikibot/exceptions.py
===================================================================
--- branches/rewrite/pywikibot/exceptions.py 2009-04-15 07:37:43 UTC (rev 6606)
+++ branches/rewrite/pywikibot/exceptions.py 2009-04-15 08:28:21 UTC (rev 6607)
@@ -18,12 +18,15 @@
class Error(Exception):
"""Wikipedia error"""
def __init__(self, arg):
+ self.unicode = arg
try:
self.string = arg.encode(config.console_encoding, "xmlcharrefreplace")
except (AttributeError, TypeError):
self.string = arg.encode("ascii", "xmlcharrefreplace")
def __str__(self):
return self.string
+ def __unicode__(self):
+ return self.unicode
class PageRelatedError(Error):
"""Abstract Exception, used when the Exception concerns a particular
@@ -72,8 +75,9 @@
"""
-class LockedPage(Error):
+class LockedPage(PageRelatedError):
"""Page is locked"""
+ message = u"Page %s is locked."
class SectionError(Error):
"""The section specified by # does not exist"""