~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
132
132
            if isinstance(s, unicode):
133
133
                return s.encode('utf8')
134
134
            return s
135
 
        except (NameError, ValueError, KeyError), e:
136
 
            return 'Unprintable exception %s: %s' \
137
 
                % (self.__class__.__name__, str(e))
 
135
        except (TypeError, NameError, ValueError, KeyError), e:
 
136
            return 'Unprintable exception %s(%r): %s' \
 
137
                % (self.__class__.__name__,
 
138
                   self.__dict__, str(e))
 
139
 
 
140
 
 
141
class AlreadyBuilding(BzrNewError):
 
142
    """The tree builder is already building a tree."""
138
143
 
139
144
 
140
145
class BzrCheckError(BzrNewError):
191
196
        self.base = base
192
197
 
193
198
 
 
199
class NotBuilding(BzrNewError):
 
200
    """Not currently building a tree."""
 
201
 
 
202
 
194
203
class NotLocalUrl(BzrNewError):
195
204
    """%(url)s is not a local path."""
196
205
    
285
294
        PathError.__init__(self, url, extra=extra)
286
295
 
287
296
 
 
297
class ShortReadvError(PathError):
 
298
    """readv() read %(actual)s bytes rather than %(length)s bytes at %(offset)s for %(path)s%(extra)s"""
 
299
 
 
300
    is_user_error = False
 
301
 
 
302
    def __init__(self, path, offset, length, actual, extra=None):
 
303
        PathError.__init__(self, path, extra=extra)
 
304
        self.offset = offset
 
305
        self.length = length
 
306
        self.actual = actual
 
307
 
 
308
 
288
309
class PathNotChild(BzrNewError):
289
310
    """Path %(path)r is not a child of path %(base)r%(extra)s"""
290
311
 
790
811
        BzrNewError.__init__(self)
791
812
 
792
813
 
 
814
class SmartProtocolError(TransportError):
 
815
    """Generic bzr smart protocol error: %(details)s"""
 
816
 
 
817
    def __init__(self, details):
 
818
        self.details = details
 
819
 
 
820
 
793
821
# A set of semi-meaningful errors which can be thrown
794
822
class TransportNotPossible(TransportError):
795
823
    """Transport operation not possible: %(msg)s %(orig_error)%"""
1182
1210
        BadInventoryFormat.__init__(self, msg=msg)
1183
1211
 
1184
1212
 
 
1213
class NoSmartServer(NotBranchError):
 
1214
    """No smart server available at %(url)s"""
 
1215
 
 
1216
    def __init__(self, url):
 
1217
        self.url = url
 
1218
 
 
1219
 
1185
1220
class UnknownSSH(BzrNewError):
1186
1221
    """Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1187
1222
 
1196
1231
    def __init__(self, revision_id):
1197
1232
        BzrNewError.__init__(self)
1198
1233
        self.revision_id = revision_id
 
1234
 
 
1235
 
 
1236
class IllegalUseOfScopeReplacer(BzrNewError):
 
1237
    """ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
 
1238
 
 
1239
    is_user_error = False
 
1240
 
 
1241
    def __init__(self, name, msg, extra=None):
 
1242
        BzrNewError.__init__(self)
 
1243
        self.name = name
 
1244
        self.msg = msg
 
1245
        if extra:
 
1246
            self.extra = ': ' + str(extra)
 
1247
        else:
 
1248
            self.extra = ''
 
1249
 
 
1250
 
 
1251
class InvalidImportLine(BzrNewError):
 
1252
    """Not a valid import statement: %(msg)\n%(text)s"""
 
1253
 
 
1254
    is_user_error = False
 
1255
 
 
1256
    def __init__(self, text, msg):
 
1257
        BzrNewError.__init__(self)
 
1258
        self.text = text
 
1259
        self.msg = msg
 
1260
 
 
1261
 
 
1262
class ImportNameCollision(BzrNewError):
 
1263
    """Tried to import an object to the same name as an existing object. %(name)s"""
 
1264
 
 
1265
    is_user_error = False
 
1266
 
 
1267
    def __init__(self, name):
 
1268
        BzrNewError.__init__(self)
 
1269
        self.name = name