/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: Jan Balster
  • Date: 2006-08-15 12:39:42 UTC
  • mfrom: (1923 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1928.
  • Revision ID: jan@merlinux.de-20060815123942-22c388c6e9a8ac91
merge bzr.dev 1923

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006 Canonical
2
 
 
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
258
258
        self.args.extend(args)
259
259
 
260
260
 
 
261
class UnsupportedProtocol(PathError):
 
262
    """Unsupported protocol for url "%(path)s"%(extra)s"""
 
263
 
 
264
    def __init__(self, url, extra):
 
265
        PathError.__init__(self, url, extra=extra)
 
266
 
 
267
 
261
268
class PathNotChild(BzrNewError):
262
269
    """Path %(path)r is not a child of path %(base)r%(extra)s"""
263
270
 
273
280
            self.extra = ''
274
281
 
275
282
 
 
283
class InvalidNormalization(PathError):
 
284
    """Path %(path)r is not unicode normalized"""
 
285
 
 
286
 
276
287
# TODO: This is given a URL; we try to unescape it but doing that from inside
277
288
# the exception object is a bit undesirable.
278
289
# TODO: Probably this behavior of should be a common superclass 
293
304
(use bzr checkout if you wish to build a working tree): %(path)s"""
294
305
 
295
306
 
 
307
class AtomicFileAlreadyClosed(PathError):
 
308
    """'%(function)s' called on an AtomicFile after it was closed: %(path)s"""
 
309
 
 
310
    def __init__(self, path, function):
 
311
        PathError.__init__(self, path=path, extra=None)
 
312
        self.function = function
 
313
 
 
314
 
 
315
class InaccessibleParent(PathError):
 
316
    """Parent not accessible given base %(base)s and relative path %(path)s"""
 
317
 
 
318
    def __init__(self, path, base):
 
319
        PathError.__init__(self, path)
 
320
        self.base = base
 
321
 
 
322
 
296
323
class NoRepositoryPresent(BzrNewError):
297
324
    """No repository present: %(path)r"""
298
325
    def __init__(self, bzrdir):
710
737
        self.format = format
711
738
 
712
739
 
713
 
class TransportError(BzrError):
714
 
    """All errors thrown by Transport implementations should derive
715
 
    from this class.
716
 
    """
 
740
class TransportError(BzrNewError):
 
741
    """Transport error: %(msg)s %(orig_error)s"""
 
742
 
717
743
    def __init__(self, msg=None, orig_error=None):
718
744
        if msg is None and orig_error is not None:
719
745
            msg = str(orig_error)
720
 
        BzrError.__init__(self, msg)
 
746
        if orig_error is None:
 
747
            orig_error = ''
 
748
        if msg is None:
 
749
            msg =  ''
721
750
        self.msg = msg
722
751
        self.orig_error = orig_error
 
752
        BzrNewError.__init__(self)
723
753
 
724
754
 
725
755
# A set of semi-meaningful errors which can be thrown
726
756
class TransportNotPossible(TransportError):
727
 
    """This is for transports where a specific function is explicitly not
728
 
    possible. Such as pushing files to an HTTP server.
729
 
    """
730
 
    pass
 
757
    """Transport operation not possible: %(msg)s %(orig_error)%"""
731
758
 
732
759
 
733
760
class ConnectionError(TransportError):
734
 
    """A connection problem prevents file retrieval.
735
 
    This does not indicate whether the file exists or not; it indicates that a
736
 
    precondition for requesting the file was not met.
737
 
    """
738
 
    def __init__(self, msg=None, orig_error=None):
739
 
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
 
761
    """Connection error: %(msg)s %(orig_error)s"""
740
762
 
741
763
 
742
764
class ConnectionReset(TransportError):
743
 
    """The connection has been closed."""
744
 
    pass
 
765
    """Connection closed: %(msg)s %(orig_error)s"""
 
766
 
 
767
 
 
768
class InvalidRange(TransportError):
 
769
    """Invalid range access."""
 
770
    
 
771
    def __init__(self, path, offset):
 
772
        TransportError.__init__(self, ("Invalid range access in %s at %d"
 
773
                                       % (path, offset)))
 
774
 
 
775
 
 
776
class InvalidHttpResponse(TransportError):
 
777
    """Invalid http response for %(path)s: %(msg)s"""
 
778
 
 
779
    def __init__(self, path, msg, orig_error=None):
 
780
        self.path = path
 
781
        TransportError.__init__(self, msg, orig_error=orig_error)
 
782
 
 
783
 
 
784
class InvalidHttpRange(InvalidHttpResponse):
 
785
    """Invalid http range "%(range)s" for %(path)s: %(msg)s"""
 
786
    
 
787
    def __init__(self, path, range, msg):
 
788
        self.range = range
 
789
        InvalidHttpResponse.__init__(self, path, msg)
 
790
 
 
791
 
 
792
class InvalidHttpContentType(InvalidHttpResponse):
 
793
    """Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s"""
 
794
    
 
795
    def __init__(self, path, ctype, msg):
 
796
        self.ctype = ctype
 
797
        InvalidHttpResponse.__init__(self, path, msg)
745
798
 
746
799
 
747
800
class ConflictsInTree(BzrError):
897
950
    """Diff is not installed on this machine: %(msg)s"""
898
951
 
899
952
    def __init__(self, msg):
900
 
        super(NoDiff, self).__init__(msg=msg)
 
953
        BzrNewError.__init__(self, msg=msg)
901
954
 
902
955
 
903
956
class NoDiff3(BzrNewError):
965
1018
    """A nested progress bar was not 'finished' correctly."""
966
1019
 
967
1020
 
 
1021
class InvalidProgressBarType(BzrNewError):
 
1022
    """Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
 
1023
Select one of: %(valid_types)s"""
 
1024
 
 
1025
    def __init__(self, bar_type, valid_types):
 
1026
        BzrNewError.__init__(self, bar_type=bar_type, valid_types=valid_types)
 
1027
 
 
1028
 
968
1029
class UnsupportedOperation(BzrNewError):
969
1030
    """The method %(mname)s is not supported on objects of type %(tname)s."""
970
1031
    def __init__(self, method, method_self):
1000
1061
    """Not a bzr revision-bundle: %(text)r"""
1001
1062
 
1002
1063
    def __init__(self, text):
1003
 
        self.text = text
1004
 
 
1005
 
 
1006
 
class BadBundle(Exception): pass
1007
 
 
1008
 
 
1009
 
class MalformedHeader(BadBundle): pass
1010
 
 
1011
 
 
1012
 
class MalformedPatches(BadBundle): pass
1013
 
 
1014
 
 
1015
 
class MalformedFooter(BadBundle): pass
 
1064
        BzrNewError.__init__(self)
 
1065
        self.text = text
 
1066
 
 
1067
 
 
1068
class BadBundle(BzrNewError): 
 
1069
    """Bad bzr revision-bundle: %(text)r"""
 
1070
 
 
1071
    def __init__(self, text):
 
1072
        BzrNewError.__init__(self)
 
1073
        self.text = text
 
1074
 
 
1075
 
 
1076
class MalformedHeader(BadBundle): 
 
1077
    """Malformed bzr revision-bundle header: %(text)r"""
 
1078
 
 
1079
    def __init__(self, text):
 
1080
        BzrNewError.__init__(self)
 
1081
        self.text = text
 
1082
 
 
1083
 
 
1084
class MalformedPatches(BadBundle): 
 
1085
    """Malformed patches in bzr revision-bundle: %(text)r"""
 
1086
 
 
1087
    def __init__(self, text):
 
1088
        BzrNewError.__init__(self)
 
1089
        self.text = text
 
1090
 
 
1091
 
 
1092
class MalformedFooter(BadBundle): 
 
1093
    """Malformed footer in bzr revision-bundle: %(text)r"""
 
1094
 
 
1095
    def __init__(self, text):
 
1096
        BzrNewError.__init__(self)
 
1097
        self.text = text
 
1098
 
 
1099
class UnsupportedEOLMarker(BadBundle):
 
1100
    """End of line marker was not \\n in bzr revision-bundle"""    
 
1101
 
 
1102
    def __init__(self):
 
1103
        BzrNewError.__init__(self)