-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy patherrors.py
72 lines (51 loc) · 2.05 KB
/
errors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.
"""Errors used by the charm."""
from __future__ import annotations
from typing import Union
# we import the errors from the module, these are used in the charm
from github_runner_manager.errors import ( # noqa: F401 pylint: disable=unused-import
GithubMetricsError,
PlatformClientError,
RunnerError,
TokenError,
)
class ConfigurationError(Exception):
"""Error for juju configuration."""
class MissingMongoDBError(Exception):
"""Error for missing integration data."""
class SubprocessError(Exception):
"""Error for Subprocess calls.
Attributes:
cmd: Command in list form.
return_code: Return code of the subprocess.
stdout: Content of stdout of the subprocess.
stderr: Content of stderr of the subprocess.
"""
def __init__(
self,
cmd: list[str],
return_code: int,
stdout: Union[bytes, str],
stderr: Union[bytes, str],
):
"""Construct the subprocess error.
Args:
cmd: Command in list form.
return_code: Return code of the subprocess.
stdout: Content of stdout of the subprocess.
stderr: Content of stderr of the subprocess.
"""
super().__init__(f"[{' '.join(cmd)}] failed with return code {return_code!r}: {stderr!r}")
self.cmd = cmd
self.return_code = return_code
self.stdout = stdout
self.stderr = stderr
class LogrotateSetupError(Exception):
"""Represents an error raised when logrotate cannot be setup."""
class RunnerManagerApplicationError(Exception):
"""Represents an error raised with github-runner-manager application."""
class RunnerManagerApplicationInstallError(RunnerManagerApplicationError):
"""Represents an error raised when github-runner-manager application installation failed."""
class RunnerManagerApplicationStartupError(RunnerManagerApplicationError):
"""Represents an error raised when github-runner-manager application start up failed."""