1
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
2
|
|
3
|
# Error classes.
|
4
|
#
|
5
|
# This file is part of Hydrilla
|
6
|
#
|
7
|
# Copyright (C) 2022 Wojtek Kosior
|
8
|
#
|
9
|
# This program is free software: you can redistribute it and/or modify
|
10
|
# it under the terms of the GNU Affero General Public License as
|
11
|
# published by the Free Software Foundation, either version 3 of the
|
12
|
# License, or (at your option) any later version.
|
13
|
#
|
14
|
# This program is distributed in the hope that it will be useful,
|
15
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
# GNU Affero General Public License for more details.
|
18
|
#
|
19
|
# You should have received a copy of the GNU Affero General Public License
|
20
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
21
|
#
|
22
|
#
|
23
|
# I, Wojtek Kosior, thereby promise not to sue for violation of this
|
24
|
# file's license. Although I request that you do not make use this code
|
25
|
# in a proprietary program, I am not going to enforce this in court.
|
26
|
|
27
|
"""
|
28
|
This module defines error types for use in other parts of Hydrilla builder.
|
29
|
"""
|
30
|
|
31
|
# Enable using with Python 3.7.
|
32
|
from __future__ import annotations
|
33
|
|
34
|
from pathlib import Path
|
35
|
|
36
|
from .. import util
|
37
|
|
38
|
here = Path(__file__).resolve().parent
|
39
|
|
40
|
_ = util.translation(here / 'locales').gettext
|
41
|
|
42
|
class DistroError(Exception):
|
43
|
"""
|
44
|
Exception used to report problems when resolving an OS distribution.
|
45
|
"""
|
46
|
|
47
|
class FileReferenceError(Exception):
|
48
|
"""
|
49
|
Exception used to report various problems concerning files referenced from
|
50
|
source package.
|
51
|
"""
|
52
|
|
53
|
class SubprocessError(Exception):
|
54
|
"""
|
55
|
Exception used to report problems related to execution of external
|
56
|
processes, includes. various problems when calling apt-* and dpkg-*
|
57
|
commands.
|
58
|
"""
|
59
|
def __init__(self, msg: str, cp: Optional[CP]=None) -> None:
|
60
|
"""Initialize this SubprocessError"""
|
61
|
if cp and cp.stdout:
|
62
|
msg = '\n\n'.join([msg, _('STDOUT_OUTPUT_heading'), cp.stdout])
|
63
|
|
64
|
if cp and cp.stderr:
|
65
|
msg = '\n\n'.join([msg, _('STDERR_OUTPUT_heading'), cp.stderr])
|
66
|
|
67
|
super().__init__(msg)
|