/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

merge

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))
197
202
    # BzrCommandError, and non-UI code should not throw a subclass of
198
203
    # BzrCommandError.  ADHB 20051211
199
204
    def __init__(self, msg):
200
 
        self.msg = msg
 
205
        # Object.__str__() must return a real string
 
206
        # returning a Unicode string is a python error.
 
207
        if isinstance(msg, unicode):
 
208
            self.msg = msg.encode('utf8')
 
209
        else:
 
210
            self.msg = msg
201
211
 
202
212
    def __str__(self):
203
213
        return self.msg
312
322
        self.function = function
313
323
 
314
324
 
 
325
class InaccessibleParent(PathError):
 
326
    """Parent not accessible given base %(base)s and relative path %(path)s"""
 
327
 
 
328
    def __init__(self, path, base):
 
329
        PathError.__init__(self, path)
 
330
        self.base = base
 
331
 
 
332
 
315
333
class NoRepositoryPresent(BzrNewError):
316
334
    """No repository present: %(path)r"""
317
335
    def __init__(self, bzrdir):
1053
1071
    """Not a bzr revision-bundle: %(text)r"""
1054
1072
 
1055
1073
    def __init__(self, text):
1056
 
        self.text = text
1057
 
 
1058
 
 
1059
 
class BadBundle(Exception): pass
1060
 
 
1061
 
 
1062
 
class MalformedHeader(BadBundle): pass
1063
 
 
1064
 
 
1065
 
class MalformedPatches(BadBundle): pass
1066
 
 
1067
 
 
1068
 
class MalformedFooter(BadBundle): pass
 
1074
        BzrNewError.__init__(self)
 
1075
        self.text = text
 
1076
 
 
1077
 
 
1078
class BadBundle(BzrNewError): 
 
1079
    """Bad bzr revision-bundle: %(text)r"""
 
1080
 
 
1081
    def __init__(self, text):
 
1082
        BzrNewError.__init__(self)
 
1083
        self.text = text
 
1084
 
 
1085
 
 
1086
class MalformedHeader(BadBundle): 
 
1087
    """Malformed bzr revision-bundle header: %(text)r"""
 
1088
 
 
1089
    def __init__(self, text):
 
1090
        BzrNewError.__init__(self)
 
1091
        self.text = text
 
1092
 
 
1093
 
 
1094
class MalformedPatches(BadBundle): 
 
1095
    """Malformed patches in bzr revision-bundle: %(text)r"""
 
1096
 
 
1097
    def __init__(self, text):
 
1098
        BzrNewError.__init__(self)
 
1099
        self.text = text
 
1100
 
 
1101
 
 
1102
class MalformedFooter(BadBundle): 
 
1103
    """Malformed footer in bzr revision-bundle: %(text)r"""
 
1104
 
 
1105
    def __init__(self, text):
 
1106
        BzrNewError.__init__(self)
 
1107
        self.text = text
 
1108
 
 
1109
class UnsupportedEOLMarker(BadBundle):
 
1110
    """End of line marker was not \\n in bzr revision-bundle"""    
 
1111
 
 
1112
    def __init__(self):
 
1113
        BzrNewError.__init__(self)