error.py 3.1 KB

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