error.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. # 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. class ManifestParseError(Exception):
  15. """Failed to parse the manifest file.
  16. """
  17. class ManifestInvalidRevisionError(Exception):
  18. """The revision value in a project is incorrect.
  19. """
  20. class ManifestInvalidPathError(Exception):
  21. """A path used in <copyfile> or <linkfile> is incorrect.
  22. """
  23. class NoManifestException(Exception):
  24. """The required manifest does not exist.
  25. """
  26. def __init__(self, path, reason):
  27. super(NoManifestException, self).__init__()
  28. self.path = path
  29. self.reason = reason
  30. def __str__(self):
  31. return self.reason
  32. class EditorError(Exception):
  33. """Unspecified error from the user's text editor.
  34. """
  35. def __init__(self, reason):
  36. super(EditorError, self).__init__()
  37. self.reason = reason
  38. def __str__(self):
  39. return self.reason
  40. class GitError(Exception):
  41. """Unspecified internal error from git.
  42. """
  43. def __init__(self, command):
  44. super(GitError, self).__init__()
  45. self.command = command
  46. def __str__(self):
  47. return self.command
  48. class UploadError(Exception):
  49. """A bundle upload to Gerrit did not succeed.
  50. """
  51. def __init__(self, reason):
  52. super(UploadError, self).__init__()
  53. self.reason = reason
  54. def __str__(self):
  55. return self.reason
  56. class DownloadError(Exception):
  57. """Cannot download a repository.
  58. """
  59. def __init__(self, reason):
  60. super(DownloadError, self).__init__()
  61. self.reason = reason
  62. def __str__(self):
  63. return self.reason
  64. class NoSuchProjectError(Exception):
  65. """A specified project does not exist in the work tree.
  66. """
  67. def __init__(self, name=None):
  68. super(NoSuchProjectError, self).__init__()
  69. self.name = name
  70. def __str__(self):
  71. if self.name is None:
  72. return 'in current directory'
  73. return self.name
  74. class InvalidProjectGroupsError(Exception):
  75. """A specified project is not suitable for the specified groups
  76. """
  77. def __init__(self, name=None):
  78. super(InvalidProjectGroupsError, self).__init__()
  79. self.name = name
  80. def __str__(self):
  81. if self.name is None:
  82. return 'in current directory'
  83. return self.name
  84. class RepoChangedException(Exception):
  85. """Thrown if 'repo sync' results in repo updating its internal
  86. repo or manifest repositories. In this special case we must
  87. use exec to re-execute repo with the new code and manifest.
  88. """
  89. def __init__(self, extra_args=None):
  90. super(RepoChangedException, self).__init__()
  91. self.extra_args = extra_args or []
  92. class HookError(Exception):
  93. """Thrown if a 'repo-hook' could not be run.
  94. The common case is that the file wasn't present when we tried to run it.
  95. """