/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

Merge from bzr.dev

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 
710
721
        self.format = format
711
722
 
712
723
 
713
 
class TransportError(BzrError):
714
 
    """All errors thrown by Transport implementations should derive
715
 
    from this class.
716
 
    """
 
724
class TransportError(BzrNewError):
 
725
    """Transport error: %(msg)s %(orig_error)s"""
 
726
 
717
727
    def __init__(self, msg=None, orig_error=None):
718
728
        if msg is None and orig_error is not None:
719
729
            msg = str(orig_error)
720
 
        BzrError.__init__(self, msg)
 
730
        if orig_error is None:
 
731
            orig_error = ''
 
732
        if msg is None:
 
733
            msg =  ''
721
734
        self.msg = msg
722
735
        self.orig_error = orig_error
 
736
        BzrNewError.__init__(self)
723
737
 
724
738
 
725
739
# A set of semi-meaningful errors which can be thrown
726
740
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
 
741
    """Transport operation not possible: %(msg)s %(orig_error)%"""
731
742
 
732
743
 
733
744
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)
 
745
    """Connection error: %(msg)s %(orig_error)s"""
740
746
 
741
747
 
742
748
class ConnectionReset(TransportError):
743
 
    """The connection has been closed."""
744
 
    pass
 
749
    """Connection closed: %(msg)s %(orig_error)s"""
 
750
 
 
751
 
 
752
class InvalidRange(TransportError):
 
753
    """Invalid range access."""
 
754
    
 
755
    def __init__(self, path, offset):
 
756
        TransportError.__init__(self, ("Invalid range access in %s at %d"
 
757
                                       % (path, offset)))
 
758
 
 
759
 
 
760
class InvalidHttpResponse(TransportError):
 
761
    """Invalid http response for %(path)s: %(msg)s"""
 
762
 
 
763
    def __init__(self, path, msg, orig_error=None):
 
764
        self.path = path
 
765
        TransportError.__init__(self, msg, orig_error=orig_error)
 
766
 
 
767
 
 
768
class InvalidHttpRange(InvalidHttpResponse):
 
769
    """Invalid http range "%(range)s" for %(path)s: %(msg)s"""
 
770
    
 
771
    def __init__(self, path, range, msg):
 
772
        self.range = range
 
773
        InvalidHttpResponse.__init__(self, path, msg)
 
774
 
 
775
 
 
776
class InvalidHttpContentType(InvalidHttpResponse):
 
777
    """Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s"""
 
778
    
 
779
    def __init__(self, path, ctype, msg):
 
780
        self.ctype = ctype
 
781
        InvalidHttpResponse.__init__(self, path, msg)
745
782
 
746
783
 
747
784
class ConflictsInTree(BzrError):
911
948
    """Diff is not installed on this machine: %(msg)s"""
912
949
 
913
950
    def __init__(self, msg):
914
 
        super(NoDiff, self).__init__(msg=msg)
 
951
        BzrNewError.__init__(self, msg=msg)
915
952
 
916
953
 
917
954
class NoDiff3(BzrNewError):
979
1016
    """A nested progress bar was not 'finished' correctly."""
980
1017
 
981
1018
 
 
1019
class InvalidProgressBarType(BzrNewError):
 
1020
    """Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
 
1021
Select one of: %(valid_types)s"""
 
1022
 
 
1023
    def __init__(self, bar_type, valid_types):
 
1024
        BzrNewError.__init__(self, bar_type=bar_type, valid_types=valid_types)
 
1025
 
 
1026
 
982
1027
class UnsupportedOperation(BzrNewError):
983
1028
    """The method %(mname)s is not supported on objects of type %(tname)s."""
984
1029
    def __init__(self, method, method_self):