blob: cfed8083e1abf8e5dd803e9354685c8ae313ff22 [file] [log] [blame]
Mike Frysingerf6013762019-06-13 02:30:51 -04001# -*- coding:utf-8 -*-
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07002#
3# Copyright (C) 2008 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
David Pursehouse819827a2020-02-12 15:20:19 +090017
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070018class ManifestParseError(Exception):
19 """Failed to parse the manifest file.
20 """
21
David Pursehouse819827a2020-02-12 15:20:19 +090022
Shawn O. Pearce559b8462009-03-02 12:56:08 -080023class ManifestInvalidRevisionError(Exception):
24 """The revision value in a project is incorrect.
25 """
26
David Pursehouse819827a2020-02-12 15:20:19 +090027
Mike Frysinger04122b72019-07-31 23:32:58 -040028class ManifestInvalidPathError(Exception):
29 """A path used in <copyfile> or <linkfile> is incorrect.
30 """
31
David Pursehouse819827a2020-02-12 15:20:19 +090032
Conley Owens75ee0572012-11-15 17:33:11 -080033class NoManifestException(Exception):
34 """The required manifest does not exist.
35 """
David Pursehouse819827a2020-02-12 15:20:19 +090036
Dan Sandler53e902a2014-03-09 13:20:02 -040037 def __init__(self, path, reason):
38 super(NoManifestException, self).__init__()
39 self.path = path
40 self.reason = reason
41
42 def __str__(self):
43 return self.reason
Conley Owens75ee0572012-11-15 17:33:11 -080044
David Pursehouse819827a2020-02-12 15:20:19 +090045
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070046class EditorError(Exception):
47 """Unspecified error from the user's text editor.
48 """
David Pursehouse819827a2020-02-12 15:20:19 +090049
Shawn O. Pearce54fccd72009-06-24 07:09:51 -070050 def __init__(self, reason):
David Pursehouse5c6eeac2012-10-11 16:44:48 +090051 super(EditorError, self).__init__()
Shawn O. Pearce54fccd72009-06-24 07:09:51 -070052 self.reason = reason
53
54 def __str__(self):
55 return self.reason
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070056
David Pursehouse819827a2020-02-12 15:20:19 +090057
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070058class GitError(Exception):
59 """Unspecified internal error from git.
60 """
David Pursehouse819827a2020-02-12 15:20:19 +090061
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070062 def __init__(self, command):
David Pursehouse5c6eeac2012-10-11 16:44:48 +090063 super(GitError, self).__init__()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070064 self.command = command
65
66 def __str__(self):
67 return self.command
68
David Pursehouse819827a2020-02-12 15:20:19 +090069
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070070class UploadError(Exception):
71 """A bundle upload to Gerrit did not succeed.
72 """
David Pursehouse819827a2020-02-12 15:20:19 +090073
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070074 def __init__(self, reason):
David Pursehouse5c6eeac2012-10-11 16:44:48 +090075 super(UploadError, self).__init__()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070076 self.reason = reason
77
78 def __str__(self):
79 return self.reason
80
David Pursehouse819827a2020-02-12 15:20:19 +090081
Shawn O. Pearcef322b9a2011-09-19 14:50:58 -070082class DownloadError(Exception):
83 """Cannot download a repository.
84 """
David Pursehouse819827a2020-02-12 15:20:19 +090085
Shawn O. Pearcef322b9a2011-09-19 14:50:58 -070086 def __init__(self, reason):
David Pursehouse5c6eeac2012-10-11 16:44:48 +090087 super(DownloadError, self).__init__()
Shawn O. Pearcef322b9a2011-09-19 14:50:58 -070088 self.reason = reason
89
90 def __str__(self):
91 return self.reason
92
David Pursehouse819827a2020-02-12 15:20:19 +090093
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070094class NoSuchProjectError(Exception):
95 """A specified project does not exist in the work tree.
96 """
David Pursehouse819827a2020-02-12 15:20:19 +090097
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070098 def __init__(self, name=None):
David Pursehouse5c6eeac2012-10-11 16:44:48 +090099 super(NoSuchProjectError, self).__init__()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700100 self.name = name
101
102 def __str__(self):
Anthony Kingbe4456c2015-06-03 16:59:18 +0100103 if self.name is None:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700104 return 'in current directory'
105 return self.name
106
Colin Cross5acde752012-03-28 20:15:45 -0700107
108class InvalidProjectGroupsError(Exception):
109 """A specified project is not suitable for the specified groups
110 """
David Pursehouse819827a2020-02-12 15:20:19 +0900111
Colin Cross5acde752012-03-28 20:15:45 -0700112 def __init__(self, name=None):
David Pursehouse5c6eeac2012-10-11 16:44:48 +0900113 super(InvalidProjectGroupsError, self).__init__()
Colin Cross5acde752012-03-28 20:15:45 -0700114 self.name = name
115
116 def __str__(self):
Anthony Kingbe4456c2015-06-03 16:59:18 +0100117 if self.name is None:
Colin Cross5acde752012-03-28 20:15:45 -0700118 return 'in current directory'
119 return self.name
120
David Pursehouse819827a2020-02-12 15:20:19 +0900121
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700122class RepoChangedException(Exception):
123 """Thrown if 'repo sync' results in repo updating its internal
124 repo or manifest repositories. In this special case we must
125 use exec to re-execute repo with the new code and manifest.
126 """
David Pursehouse819827a2020-02-12 15:20:19 +0900127
David Pursehouse8a68ff92012-09-24 12:15:13 +0900128 def __init__(self, extra_args=None):
David Pursehouse5c6eeac2012-10-11 16:44:48 +0900129 super(RepoChangedException, self).__init__()
David Pursehouse8a68ff92012-09-24 12:15:13 +0900130 self.extra_args = extra_args or []
Doug Anderson37282b42011-03-04 11:54:18 -0800131
David Pursehouse819827a2020-02-12 15:20:19 +0900132
Doug Anderson37282b42011-03-04 11:54:18 -0800133class HookError(Exception):
134 """Thrown if a 'repo-hook' could not be run.
135
136 The common case is that the file wasn't present when we tried to run it.
137 """