/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Carl Friedrich Bolz
  • Date: 2006-09-06 21:17:22 UTC
  • mfrom: (1977 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2026.
  • Revision ID: cfbolz@gmx.de-20060906211722-b04f9c3ad1f53ef1
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
 
127
127
    def __str__(self):
128
128
        try:
129
 
            return self.__doc__ % self.__dict__
 
129
            # __str__() should always return a 'str' object
 
130
            # never a 'unicode' object.
 
131
            s = self.__doc__ % self.__dict__
 
132
            if isinstance(s, unicode):
 
133
                return s.encode('utf8')
 
134
            return s
130
135
        except (NameError, ValueError, KeyError), e:
131
136
            return 'Unprintable exception %s: %s' \
132
137
                % (self.__class__.__name__, str(e))
161
166
 
162
167
class InvalidRevisionId(BzrNewError):
163
168
    """Invalid revision-id {%(revision_id)s} in %(branch)s"""
 
169
 
164
170
    def __init__(self, revision_id, branch):
165
171
        # branch can be any string or object with __str__ defined
166
172
        BzrNewError.__init__(self)
197
203
    # BzrCommandError, and non-UI code should not throw a subclass of
198
204
    # BzrCommandError.  ADHB 20051211
199
205
    def __init__(self, msg):
200
 
        self.msg = msg
 
206
        # Object.__str__() must return a real string
 
207
        # returning a Unicode string is a python error.
 
208
        if isinstance(msg, unicode):
 
209
            self.msg = msg.encode('utf8')
 
210
        else:
 
211
            self.msg = msg
201
212
 
202
213
    def __str__(self):
203
214
        return self.msg
1096
1107
        BzrNewError.__init__(self)
1097
1108
        self.text = text
1098
1109
 
 
1110
 
1099
1111
class UnsupportedEOLMarker(BadBundle):
1100
1112
    """End of line marker was not \\n in bzr revision-bundle"""    
1101
1113
 
1102
1114
    def __init__(self):
1103
 
        BzrNewError.__init__(self)    
 
1115
        BzrNewError.__init__(self)
 
1116
 
 
1117
 
 
1118
class UnknownSSH(BzrNewError):
 
1119
    """Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
 
1120
 
 
1121
    def __init__(self, vendor):
 
1122
        BzrNewError.__init__(self)
 
1123
        self.vendor = vendor
 
1124
 
 
1125
 
 
1126
class GhostRevisionUnusableHere(BzrNewError):
 
1127
    """Ghost revision {%(revision_id)s} cannot be used here."""
 
1128
 
 
1129
    def __init__(self, revision_id):
 
1130
        BzrNewError.__init__(self)
 
1131
        self.revision_id = revision_id