blob: cbefcb7e188da639b6dc1ee68eb6eb7150c2681c [file] [log] [blame]
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07001# Copyright (C) 2008 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
David Pursehouse819827a2020-02-12 15:20:19 +090015
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070016class ManifestParseError(Exception):
17 """Failed to parse the manifest file.
18 """
19
David Pursehouse819827a2020-02-12 15:20:19 +090020
Mike Frysinger54133972021-03-01 21:38:08 -050021class ManifestInvalidRevisionError(ManifestParseError):
Shawn O. Pearce559b8462009-03-02 12:56:08 -080022 """The revision value in a project is incorrect.
23 """
24
David Pursehouse819827a2020-02-12 15:20:19 +090025
Mike Frysinger54133972021-03-01 21:38:08 -050026class ManifestInvalidPathError(ManifestParseError):
Mike Frysinger04122b72019-07-31 23:32:58 -040027 """A path used in <copyfile> or <linkfile> is incorrect.
28 """
29
David Pursehouse819827a2020-02-12 15:20:19 +090030
Conley Owens75ee0572012-11-15 17:33:11 -080031class NoManifestException(Exception):
32 """The required manifest does not exist.
33 """
David Pursehouse819827a2020-02-12 15:20:19 +090034
Dan Sandler53e902a2014-03-09 13:20:02 -040035 def __init__(self, path, reason):
Mike Frysinger5d9c4972021-02-19 13:34:09 -050036 super().__init__(path, reason)
Dan Sandler53e902a2014-03-09 13:20:02 -040037 self.path = path
38 self.reason = reason
39
40 def __str__(self):
41 return self.reason
Conley Owens75ee0572012-11-15 17:33:11 -080042
David Pursehouse819827a2020-02-12 15:20:19 +090043
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070044class EditorError(Exception):
45 """Unspecified error from the user's text editor.
46 """
David Pursehouse819827a2020-02-12 15:20:19 +090047
Shawn O. Pearce54fccd72009-06-24 07:09:51 -070048 def __init__(self, reason):
Mike Frysinger5d9c4972021-02-19 13:34:09 -050049 super().__init__(reason)
Shawn O. Pearce54fccd72009-06-24 07:09:51 -070050 self.reason = reason
51
52 def __str__(self):
53 return self.reason
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070054
David Pursehouse819827a2020-02-12 15:20:19 +090055
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070056class GitError(Exception):
57 """Unspecified internal error from git.
58 """
David Pursehouse819827a2020-02-12 15:20:19 +090059
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070060 def __init__(self, command):
Mike Frysinger5d9c4972021-02-19 13:34:09 -050061 super().__init__(command)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070062 self.command = command
63
64 def __str__(self):
65 return self.command
66
David Pursehouse819827a2020-02-12 15:20:19 +090067
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070068class UploadError(Exception):
69 """A bundle upload to Gerrit did not succeed.
70 """
David Pursehouse819827a2020-02-12 15:20:19 +090071
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070072 def __init__(self, reason):
Mike Frysinger5d9c4972021-02-19 13:34:09 -050073 super().__init__(reason)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070074 self.reason = reason
75
76 def __str__(self):
77 return self.reason
78
David Pursehouse819827a2020-02-12 15:20:19 +090079
Shawn O. Pearcef322b9a2011-09-19 14:50:58 -070080class DownloadError(Exception):
81 """Cannot download a repository.
82 """
David Pursehouse819827a2020-02-12 15:20:19 +090083
Shawn O. Pearcef322b9a2011-09-19 14:50:58 -070084 def __init__(self, reason):
Mike Frysinger5d9c4972021-02-19 13:34:09 -050085 super().__init__(reason)
Shawn O. Pearcef322b9a2011-09-19 14:50:58 -070086 self.reason = reason
87
88 def __str__(self):
89 return self.reason
90
David Pursehouse819827a2020-02-12 15:20:19 +090091
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070092class NoSuchProjectError(Exception):
93 """A specified project does not exist in the work tree.
94 """
David Pursehouse819827a2020-02-12 15:20:19 +090095
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070096 def __init__(self, name=None):
Mike Frysinger5d9c4972021-02-19 13:34:09 -050097 super().__init__(name)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070098 self.name = name
99
100 def __str__(self):
Anthony Kingbe4456c2015-06-03 16:59:18 +0100101 if self.name is None:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700102 return 'in current directory'
103 return self.name
104
Colin Cross5acde752012-03-28 20:15:45 -0700105
106class InvalidProjectGroupsError(Exception):
107 """A specified project is not suitable for the specified groups
108 """
David Pursehouse819827a2020-02-12 15:20:19 +0900109
Colin Cross5acde752012-03-28 20:15:45 -0700110 def __init__(self, name=None):
Mike Frysinger5d9c4972021-02-19 13:34:09 -0500111 super().__init__(name)
Colin Cross5acde752012-03-28 20:15:45 -0700112 self.name = name
113
114 def __str__(self):
Anthony Kingbe4456c2015-06-03 16:59:18 +0100115 if self.name is None:
Colin Cross5acde752012-03-28 20:15:45 -0700116 return 'in current directory'
117 return self.name
118
David Pursehouse819827a2020-02-12 15:20:19 +0900119
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700120class RepoChangedException(Exception):
121 """Thrown if 'repo sync' results in repo updating its internal
122 repo or manifest repositories. In this special case we must
123 use exec to re-execute repo with the new code and manifest.
124 """
David Pursehouse819827a2020-02-12 15:20:19 +0900125
David Pursehouse8a68ff92012-09-24 12:15:13 +0900126 def __init__(self, extra_args=None):
Mike Frysinger5d9c4972021-02-19 13:34:09 -0500127 super().__init__(extra_args)
David Pursehouse8a68ff92012-09-24 12:15:13 +0900128 self.extra_args = extra_args or []
Doug Anderson37282b42011-03-04 11:54:18 -0800129
David Pursehouse819827a2020-02-12 15:20:19 +0900130
Doug Anderson37282b42011-03-04 11:54:18 -0800131class HookError(Exception):
132 """Thrown if a 'repo-hook' could not be run.
133
134 The common case is that the file wasn't present when we tried to run it.
135 """