/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: John Arbash Meinel
  • Date: 2006-09-05 23:09:22 UTC
  • mfrom: (1955.3.26 transport_bytes)
  • mto: This revision was merged to the branch mainline in revision 1989.
  • Revision ID: john@arbash-meinel.com-20060905230922-6ed11ce0a4b04065
[merge] transport_bytes: bring knit churn up-to-date with new *{bytes,file} functions

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
494
505
        self.format = format
495
506
 
496
507
 
497
 
 
498
508
class StrictCommitFailed(Exception):
499
509
    """Commit refused because there are unknowns in the tree."""
500
510
 
505
515
    is_user_error = False
506
516
 
507
517
    def __init__(self, branch, revision):
508
 
        self.branch = branch
509
 
        self.revision = revision
 
518
        BzrNewError.__init__(self, branch=branch, revision=revision)
 
519
 
 
520
 
 
521
class NoSuchRevisionSpec(BzrNewError):
 
522
    """No namespace registered for string: %(spec)r"""
 
523
 
 
524
    def __init__(self, spec):
 
525
        BzrNewError.__init__(self, spec=spec)
 
526
 
 
527
 
 
528
class InvalidRevisionSpec(BzrNewError):
 
529
    """Requested revision: '%(spec)s' does not exist in branch:
 
530
%(branch)s%(extra)s"""
 
531
 
 
532
    def __init__(self, spec, branch, extra=None):
 
533
        BzrNewError.__init__(self, branch=branch, spec=spec)
 
534
        if extra:
 
535
            self.extra = '\n' + str(extra)
 
536
        else:
 
537
            self.extra = ''
510
538
 
511
539
 
512
540
class HistoryMissing(BzrError):
575
603
        self.bases = bases
576
604
 
577
605
 
578
 
class NoCommits(BzrError):
 
606
class NoCommits(BzrNewError):
 
607
    """Branch %(branch)s has no commits."""
 
608
 
579
609
    def __init__(self, branch):
580
 
        msg = "Branch %s has no commits." % branch
581
 
        BzrError.__init__(self, msg)
 
610
        BzrNewError.__init__(self, branch=branch)
582
611
 
583
612
 
584
613
class UnlistableStore(BzrError):
766
795
 
767
796
 
768
797
class InvalidRange(TransportError):
769
 
    """Invalid range access."""
 
798
    """Invalid range access in %(path)s at %(offset)s."""
770
799
    
771
800
    def __init__(self, path, offset):
772
801
        TransportError.__init__(self, ("Invalid range access in %s at %d"
773
802
                                       % (path, offset)))
 
803
        self.path = path
 
804
        self.offset = offset
774
805
 
775
806
 
776
807
class InvalidHttpResponse(TransportError):
938
969
        DependencyNotPresent.__init__(self, 'paramiko', error)
939
970
 
940
971
 
 
972
class PointlessMerge(BzrNewError):
 
973
    """Nothing to merge."""
 
974
 
 
975
 
941
976
class UninitializableFormat(BzrNewError):
942
977
    """Format %(format)s cannot be initialised by this version of bzr."""
943
978
 
1096
1131
        BzrNewError.__init__(self)
1097
1132
        self.text = text
1098
1133
 
 
1134
 
1099
1135
class UnsupportedEOLMarker(BadBundle):
1100
1136
    """End of line marker was not \\n in bzr revision-bundle"""    
1101
1137
 
1102
1138
    def __init__(self):
1103
 
        BzrNewError.__init__(self)    
 
1139
        BzrNewError.__init__(self)
 
1140
 
 
1141
 
 
1142
class UnknownSSH(BzrNewError):
 
1143
    """Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
 
1144
 
 
1145
    def __init__(self, vendor):
 
1146
        BzrNewError.__init__(self)
 
1147
        self.vendor = vendor
 
1148
 
 
1149
 
 
1150
class GhostRevisionUnusableHere(BzrNewError):
 
1151
    """Ghost revision {%(revision_id)s} cannot be used here."""
 
1152
 
 
1153
    def __init__(self, revision_id):
 
1154
        BzrNewError.__init__(self)
 
1155
        self.revision_id = revision_id