~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-15 00:44:57 UTC
  • mfrom: (2009 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2050.
  • Revision ID: john@arbash-meinel.com-20060915004457-902cec0526a39337
[merge] bzr.dev 2009

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))
138
139
 
139
140
 
140
141
class BzrCheckError(BzrNewError):
166
167
 
167
168
class InvalidRevisionId(BzrNewError):
168
169
    """Invalid revision-id {%(revision_id)s} in %(branch)s"""
 
170
 
169
171
    def __init__(self, revision_id, branch):
170
172
        # branch can be any string or object with __str__ defined
171
173
        BzrNewError.__init__(self)
173
175
        self.branch = branch
174
176
 
175
177
 
 
178
class NoSuchId(BzrNewError):
 
179
    """The file id %(file_id)s is not present in the tree %(tree)s."""
 
180
    
 
181
    def __init__(self, tree, file_id):
 
182
        BzrNewError.__init__(self)
 
183
        self.file_id = file_id
 
184
        self.tree = tree
 
185
 
 
186
 
176
187
class NoWorkingTree(BzrNewError):
177
188
    """No WorkingTree exists for %(base)s."""
178
189
    
504
515
        self.format = format
505
516
 
506
517
 
507
 
 
508
518
class StrictCommitFailed(Exception):
509
519
    """Commit refused because there are unknowns in the tree."""
510
520
 
515
525
    is_user_error = False
516
526
 
517
527
    def __init__(self, branch, revision):
518
 
        self.branch = branch
519
 
        self.revision = revision
 
528
        BzrNewError.__init__(self, branch=branch, revision=revision)
 
529
 
 
530
 
 
531
class NoSuchRevisionSpec(BzrNewError):
 
532
    """No namespace registered for string: %(spec)r"""
 
533
 
 
534
    def __init__(self, spec):
 
535
        BzrNewError.__init__(self, spec=spec)
 
536
 
 
537
 
 
538
class InvalidRevisionSpec(BzrNewError):
 
539
    """Requested revision: '%(spec)s' does not exist in branch:
 
540
%(branch)s%(extra)s"""
 
541
 
 
542
    def __init__(self, spec, branch, extra=None):
 
543
        BzrNewError.__init__(self, branch=branch, spec=spec)
 
544
        if extra:
 
545
            self.extra = '\n' + str(extra)
 
546
        else:
 
547
            self.extra = ''
520
548
 
521
549
 
522
550
class HistoryMissing(BzrError):
585
613
        self.bases = bases
586
614
 
587
615
 
588
 
class NoCommits(BzrError):
 
616
class NoCommits(BzrNewError):
 
617
    """Branch %(branch)s has no commits."""
 
618
 
589
619
    def __init__(self, branch):
590
 
        msg = "Branch %s has no commits." % branch
591
 
        BzrError.__init__(self, msg)
 
620
        BzrNewError.__init__(self, branch=branch)
592
621
 
593
622
 
594
623
class UnlistableStore(BzrError):
776
805
 
777
806
 
778
807
class InvalidRange(TransportError):
779
 
    """Invalid range access."""
 
808
    """Invalid range access in %(path)s at %(offset)s."""
780
809
    
781
810
    def __init__(self, path, offset):
782
811
        TransportError.__init__(self, ("Invalid range access in %s at %d"
783
812
                                       % (path, offset)))
 
813
        self.path = path
 
814
        self.offset = offset
784
815
 
785
816
 
786
817
class InvalidHttpResponse(TransportError):
948
979
        DependencyNotPresent.__init__(self, 'paramiko', error)
949
980
 
950
981
 
 
982
class PointlessMerge(BzrNewError):
 
983
    """Nothing to merge."""
 
984
 
 
985
 
951
986
class UninitializableFormat(BzrNewError):
952
987
    """Format %(format)s cannot be initialised by this version of bzr."""
953
988
 
956
991
        self.format = format
957
992
 
958
993
 
 
994
class BadConversionTarget(BzrNewError):
 
995
    """Cannot convert to format %(format)s.  %(problem)s"""
 
996
 
 
997
    def __init__(self, problem, format):
 
998
        BzrNewError.__init__(self)
 
999
        self.problem = problem
 
1000
        self.format = format
 
1001
 
 
1002
 
959
1003
class NoDiff(BzrNewError):
960
1004
    """Diff is not installed on this machine: %(msg)s"""
961
1005
 
1106
1150
        BzrNewError.__init__(self)
1107
1151
        self.text = text
1108
1152
 
 
1153
 
1109
1154
class UnsupportedEOLMarker(BadBundle):
1110
1155
    """End of line marker was not \\n in bzr revision-bundle"""    
1111
1156
 
1112
1157
    def __init__(self):
1113
 
        BzrNewError.__init__(self)    
 
1158
        BzrNewError.__init__(self)
 
1159
 
 
1160
 
 
1161
class BadInventoryFormat(BzrNewError):
 
1162
    """Root class for inventory serialization errors"""
 
1163
 
 
1164
 
 
1165
class UnexpectedInventoryFormat(BadInventoryFormat):
 
1166
    """The inventory was not in the expected format:\n %(msg)s"""
 
1167
 
 
1168
    def __init__(self, msg):
 
1169
        BadInventoryFormat.__init__(self, msg=msg)
 
1170
 
 
1171
 
 
1172
class UnknownSSH(BzrNewError):
 
1173
    """Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
 
1174
 
 
1175
    def __init__(self, vendor):
 
1176
        BzrNewError.__init__(self)
 
1177
        self.vendor = vendor
 
1178
 
 
1179
 
 
1180
class GhostRevisionUnusableHere(BzrNewError):
 
1181
    """Ghost revision {%(revision_id)s} cannot be used here."""
 
1182
 
 
1183
    def __init__(self, revision_id):
 
1184
        BzrNewError.__init__(self)
 
1185
        self.revision_id = revision_id
 
1186
 
 
1187
 
 
1188
class IllegalUseOfScopeReplacer(BzrNewError):
 
1189
    """ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
 
1190
 
 
1191
    is_user_error = False
 
1192
 
 
1193
    def __init__(self, name, msg, extra=None):
 
1194
        BzrNewError.__init__(self)
 
1195
        self.name = name
 
1196
        self.msg = msg
 
1197
        if extra:
 
1198
            self.extra = ': ' + str(extra)
 
1199
        else:
 
1200
            self.extra = ''
 
1201
 
 
1202
 
 
1203
class InvalidImportLine(BzrNewError):
 
1204
    """Not a valid import statement: %(msg)\n%(text)s"""
 
1205
 
 
1206
    is_user_error = False
 
1207
 
 
1208
    def __init__(self, text, msg):
 
1209
        BzrNewError.__init__(self)
 
1210
        self.text = text
 
1211
        self.msg = msg
 
1212
 
 
1213
 
 
1214
class ImportNameCollision(BzrNewError):
 
1215
    """Tried to import an object to the same name as an existing object. %(name)s"""
 
1216
 
 
1217
    is_user_error = False
 
1218
 
 
1219
    def __init__(self, name):
 
1220
        BzrNewError.__init__(self)
 
1221
        self.name = name