error.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #
  2. # Copyright (C) 2008 The Android Open Source Project
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. class ManifestParseError(Exception):
  16. """Failed to parse the manifest file.
  17. """
  18. class ManifestInvalidRevisionError(Exception):
  19. """The revision value in a project is incorrect.
  20. """
  21. class EditorError(Exception):
  22. """Unspecified error from the user's text editor.
  23. """
  24. def __init__(self, reason):
  25. super(EditorError, self).__init__()
  26. self.reason = reason
  27. def __str__(self):
  28. return self.reason
  29. class GitError(Exception):
  30. """Unspecified internal error from git.
  31. """
  32. def __init__(self, command):
  33. super(GitError, self).__init__()
  34. self.command = command
  35. def __str__(self):
  36. return self.command
  37. class UploadError(Exception):
  38. """A bundle upload to Gerrit did not succeed.
  39. """
  40. def __init__(self, reason):
  41. super(UploadError, self).__init__()
  42. self.reason = reason
  43. def __str__(self):
  44. return self.reason
  45. class DownloadError(Exception):
  46. """Cannot download a repository.
  47. """
  48. def __init__(self, reason):
  49. super(DownloadError, self).__init__()
  50. self.reason = reason
  51. def __str__(self):
  52. return self.reason
  53. class NoSuchProjectError(Exception):
  54. """A specified project does not exist in the work tree.
  55. """
  56. def __init__(self, name=None):
  57. super(NoSuchProjectError, self).__init__()
  58. self.name = name
  59. def __str__(self):
  60. if self.Name is None:
  61. return 'in current directory'
  62. return self.name
  63. class InvalidProjectGroupsError(Exception):
  64. """A specified project is not suitable for the specified groups
  65. """
  66. def __init__(self, name=None):
  67. super(InvalidProjectGroupsError, 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 RepoChangedException(Exception):
  74. """Thrown if 'repo sync' results in repo updating its internal
  75. repo or manifest repositories. In this special case we must
  76. use exec to re-execute repo with the new code and manifest.
  77. """
  78. def __init__(self, extra_args=None):
  79. super(RepoChangedException, self).__init__()
  80. self.extra_args = extra_args or []
  81. class HookError(Exception):
  82. """Thrown if a 'repo-hook' could not be run.
  83. The common case is that the file wasn't present when we tried to run it.
  84. """