/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: Aaron Bentley
  • Date: 2006-09-09 18:52:57 UTC
  • mfrom: (1996 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1997.
  • Revision ID: aaron.bentley@utoronto.ca-20060909185257-ce0ee03ee5125ff1
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)
168
174
        self.branch = branch
169
175
 
170
176
 
 
177
class NoSuchId(BzrNewError):
 
178
    """The file id %(file_id)s is not present in the tree %(tree)s."""
 
179
    
 
180
    def __init__(self, tree, file_id):
 
181
        BzrNewError.__init__(self)
 
182
        self.file_id = file_id
 
183
        self.tree = tree
 
184
 
 
185
 
171
186
class NoWorkingTree(BzrNewError):
172
187
    """No WorkingTree exists for %(base)s."""
173
188
    
197
212
    # BzrCommandError, and non-UI code should not throw a subclass of
198
213
    # BzrCommandError.  ADHB 20051211
199
214
    def __init__(self, msg):
200
 
        self.msg = msg
 
215
        # Object.__str__() must return a real string
 
216
        # returning a Unicode string is a python error.
 
217
        if isinstance(msg, unicode):
 
218
            self.msg = msg.encode('utf8')
 
219
        else:
 
220
            self.msg = msg
201
221
 
202
222
    def __str__(self):
203
223
        return self.msg
494
514
        self.format = format
495
515
 
496
516
 
497
 
 
498
517
class StrictCommitFailed(Exception):
499
518
    """Commit refused because there are unknowns in the tree."""
500
519
 
505
524
    is_user_error = False
506
525
 
507
526
    def __init__(self, branch, revision):
508
 
        self.branch = branch
509
 
        self.revision = revision
 
527
        BzrNewError.__init__(self, branch=branch, revision=revision)
 
528
 
 
529
 
 
530
class NoSuchRevisionSpec(BzrNewError):
 
531
    """No namespace registered for string: %(spec)r"""
 
532
 
 
533
    def __init__(self, spec):
 
534
        BzrNewError.__init__(self, spec=spec)
 
535
 
 
536
 
 
537
class InvalidRevisionSpec(BzrNewError):
 
538
    """Requested revision: '%(spec)s' does not exist in branch:
 
539
%(branch)s%(extra)s"""
 
540
 
 
541
    def __init__(self, spec, branch, extra=None):
 
542
        BzrNewError.__init__(self, branch=branch, spec=spec)
 
543
        if extra:
 
544
            self.extra = '\n' + str(extra)
 
545
        else:
 
546
            self.extra = ''
510
547
 
511
548
 
512
549
class HistoryMissing(BzrError):
575
612
        self.bases = bases
576
613
 
577
614
 
578
 
class NoCommits(BzrError):
 
615
class NoCommits(BzrNewError):
 
616
    """Branch %(branch)s has no commits."""
 
617
 
579
618
    def __init__(self, branch):
580
 
        msg = "Branch %s has no commits." % branch
581
 
        BzrError.__init__(self, msg)
 
619
        BzrNewError.__init__(self, branch=branch)
582
620
 
583
621
 
584
622
class UnlistableStore(BzrError):
766
804
 
767
805
 
768
806
class InvalidRange(TransportError):
769
 
    """Invalid range access."""
 
807
    """Invalid range access in %(path)s at %(offset)s."""
770
808
    
771
809
    def __init__(self, path, offset):
772
810
        TransportError.__init__(self, ("Invalid range access in %s at %d"
773
811
                                       % (path, offset)))
 
812
        self.path = path
 
813
        self.offset = offset
774
814
 
775
815
 
776
816
class InvalidHttpResponse(TransportError):
938
978
        DependencyNotPresent.__init__(self, 'paramiko', error)
939
979
 
940
980
 
 
981
class PointlessMerge(BzrNewError):
 
982
    """Nothing to merge."""
 
983
 
 
984
 
941
985
class UninitializableFormat(BzrNewError):
942
986
    """Format %(format)s cannot be initialised by this version of bzr."""
943
987
 
1105
1149
        BzrNewError.__init__(self)
1106
1150
        self.text = text
1107
1151
 
 
1152
 
1108
1153
class UnsupportedEOLMarker(BadBundle):
1109
1154
    """End of line marker was not \\n in bzr revision-bundle"""    
1110
1155
 
1111
1156
    def __init__(self):
1112
 
        BzrNewError.__init__(self)    
 
1157
        BzrNewError.__init__(self)
1113
1158
 
1114
1159
 
1115
1160
class BadInventoryFormat(BzrNewError):
1121
1166
 
1122
1167
    def __init__(self, msg):
1123
1168
        BadInventoryFormat.__init__(self, msg=msg)
 
1169
 
 
1170
 
 
1171
class UnknownSSH(BzrNewError):
 
1172
    """Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
 
1173
 
 
1174
    def __init__(self, vendor):
 
1175
        BzrNewError.__init__(self)
 
1176
        self.vendor = vendor
 
1177
 
 
1178
 
 
1179
class GhostRevisionUnusableHere(BzrNewError):
 
1180
    """Ghost revision {%(revision_id)s} cannot be used here."""
 
1181
 
 
1182
    def __init__(self, revision_id):
 
1183
        BzrNewError.__init__(self)
 
1184
        self.revision_id = revision_id