1
# errors.py -- errors for dulwich
2
# Copyright (C) 2007 James Westby <jw+debian@jameswestby.net>
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; version 2
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
class WrongObjectException(Exception):
20
"""Baseclass for all the _ is not a _ exceptions on objects.
22
Do not instantiate directly.
24
Subclasses should define a _type attribute that indicates what
25
was expected if they were raised.
28
def __init__(self, sha, *args, **kwargs):
29
string = "%s is not a %s" % (sha, self._type)
30
Exception.__init__(self, string)
32
class NotCommitError(WrongObjectException):
33
"""Indicates that the sha requested does not point to a commit."""
37
class NotTreeError(WrongObjectException):
38
"""Indicates that the sha requested does not point to a tree."""
42
class NotBlobError(WrongObjectException):
43
"""Indicates that the sha requested does not point to a blob."""
47
class MissingCommitError(Exception):
48
"""Indicates that a commit was not found in the repository"""
50
def __init__(self, sha, *args, **kwargs):
51
Exception.__init__(self, "%s is not in the revision store" % sha)