blob: 3cf34d54e4565191f55d44430ce584606d6215c4 [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):
Gavin Makea2e3302023-03-11 06:46:20 +000017 """Failed to parse the manifest file."""
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070018
David Pursehouse819827a2020-02-12 15:20:19 +090019
Mike Frysinger54133972021-03-01 21:38:08 -050020class ManifestInvalidRevisionError(ManifestParseError):
Gavin Makea2e3302023-03-11 06:46:20 +000021 """The revision value in a project is incorrect."""
Shawn O. Pearce559b8462009-03-02 12:56:08 -080022
David Pursehouse819827a2020-02-12 15:20:19 +090023
Mike Frysinger54133972021-03-01 21:38:08 -050024class ManifestInvalidPathError(ManifestParseError):
Gavin Makea2e3302023-03-11 06:46:20 +000025 """A path used in <copyfile> or <linkfile> is incorrect."""
Mike Frysinger04122b72019-07-31 23:32:58 -040026
David Pursehouse819827a2020-02-12 15:20:19 +090027
Conley Owens75ee0572012-11-15 17:33:11 -080028class NoManifestException(Exception):
Gavin Makea2e3302023-03-11 06:46:20 +000029 """The required manifest does not exist."""
David Pursehouse819827a2020-02-12 15:20:19 +090030
Gavin Makea2e3302023-03-11 06:46:20 +000031 def __init__(self, path, reason):
32 super().__init__(path, reason)
33 self.path = path
34 self.reason = reason
Dan Sandler53e902a2014-03-09 13:20:02 -040035
Gavin Makea2e3302023-03-11 06:46:20 +000036 def __str__(self):
37 return self.reason
Conley Owens75ee0572012-11-15 17:33:11 -080038
David Pursehouse819827a2020-02-12 15:20:19 +090039
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070040class EditorError(Exception):
Gavin Makea2e3302023-03-11 06:46:20 +000041 """Unspecified error from the user's text editor."""
David Pursehouse819827a2020-02-12 15:20:19 +090042
Gavin Makea2e3302023-03-11 06:46:20 +000043 def __init__(self, reason):
44 super().__init__(reason)
45 self.reason = reason
Shawn O. Pearce54fccd72009-06-24 07:09:51 -070046
Gavin Makea2e3302023-03-11 06:46:20 +000047 def __str__(self):
48 return self.reason
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070049
David Pursehouse819827a2020-02-12 15:20:19 +090050
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070051class GitError(Exception):
Gavin Makea2e3302023-03-11 06:46:20 +000052 """Unspecified internal error from git."""
David Pursehouse819827a2020-02-12 15:20:19 +090053
Gavin Makea2e3302023-03-11 06:46:20 +000054 def __init__(self, command):
55 super().__init__(command)
56 self.command = command
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070057
Gavin Makea2e3302023-03-11 06:46:20 +000058 def __str__(self):
59 return self.command
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070060
David Pursehouse819827a2020-02-12 15:20:19 +090061
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070062class UploadError(Exception):
Gavin Makea2e3302023-03-11 06:46:20 +000063 """A bundle upload to Gerrit did not succeed."""
David Pursehouse819827a2020-02-12 15:20:19 +090064
Gavin Makea2e3302023-03-11 06:46:20 +000065 def __init__(self, reason):
66 super().__init__(reason)
67 self.reason = reason
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070068
Gavin Makea2e3302023-03-11 06:46:20 +000069 def __str__(self):
70 return self.reason
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070071
David Pursehouse819827a2020-02-12 15:20:19 +090072
Shawn O. Pearcef322b9a2011-09-19 14:50:58 -070073class DownloadError(Exception):
Gavin Makea2e3302023-03-11 06:46:20 +000074 """Cannot download a repository."""
David Pursehouse819827a2020-02-12 15:20:19 +090075
Gavin Makea2e3302023-03-11 06:46:20 +000076 def __init__(self, reason):
77 super().__init__(reason)
78 self.reason = reason
Shawn O. Pearcef322b9a2011-09-19 14:50:58 -070079
Gavin Makea2e3302023-03-11 06:46:20 +000080 def __str__(self):
81 return self.reason
Shawn O. Pearcef322b9a2011-09-19 14:50:58 -070082
David Pursehouse819827a2020-02-12 15:20:19 +090083
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070084class NoSuchProjectError(Exception):
Gavin Makea2e3302023-03-11 06:46:20 +000085 """A specified project does not exist in the work tree."""
David Pursehouse819827a2020-02-12 15:20:19 +090086
Gavin Makea2e3302023-03-11 06:46:20 +000087 def __init__(self, name=None):
88 super().__init__(name)
89 self.name = name
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070090
Gavin Makea2e3302023-03-11 06:46:20 +000091 def __str__(self):
92 if self.name is None:
93 return "in current directory"
94 return self.name
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070095
Colin Cross5acde752012-03-28 20:15:45 -070096
97class InvalidProjectGroupsError(Exception):
Gavin Makea2e3302023-03-11 06:46:20 +000098 """A specified project is not suitable for the specified groups"""
David Pursehouse819827a2020-02-12 15:20:19 +090099
Gavin Makea2e3302023-03-11 06:46:20 +0000100 def __init__(self, name=None):
101 super().__init__(name)
102 self.name = name
Colin Cross5acde752012-03-28 20:15:45 -0700103
Gavin Makea2e3302023-03-11 06:46:20 +0000104 def __str__(self):
105 if self.name is None:
106 return "in current directory"
107 return self.name
Colin Cross5acde752012-03-28 20:15:45 -0700108
David Pursehouse819827a2020-02-12 15:20:19 +0900109
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700110class RepoChangedException(Exception):
Gavin Makea2e3302023-03-11 06:46:20 +0000111 """Thrown if 'repo sync' results in repo updating its internal
112 repo or manifest repositories. In this special case we must
113 use exec to re-execute repo with the new code and manifest.
114 """
David Pursehouse819827a2020-02-12 15:20:19 +0900115
Gavin Makea2e3302023-03-11 06:46:20 +0000116 def __init__(self, extra_args=None):
117 super().__init__(extra_args)
118 self.extra_args = extra_args or []
Doug Anderson37282b42011-03-04 11:54:18 -0800119
David Pursehouse819827a2020-02-12 15:20:19 +0900120
Doug Anderson37282b42011-03-04 11:54:18 -0800121class HookError(Exception):
Gavin Makea2e3302023-03-11 06:46:20 +0000122 """Thrown if a 'repo-hook' could not be run.
Doug Anderson37282b42011-03-04 11:54:18 -0800123
Gavin Makea2e3302023-03-11 06:46:20 +0000124 The common case is that the file wasn't present when we tried to run it.
125 """