summaryrefslogtreecommitdiff
path: root/src/buildstream/exceptions.py
blob: 4b9118978774816951772f03d063c7eeb2d53a66 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#
#  Copyright (C) 2018 Codethink Limited
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library. If not, see <http://www.gnu.org/licenses/>.
#
#  Authors:
#        Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
#        Tiago Gomes <tiago.gomes@codethink.co.uk>
"""
Exceptions - API for Error Handling
===================================

This module contains some Enums used in Error Handling which are useful in
testing external plugins.
"""

from enum import Enum, unique


@unique
class ErrorDomain(Enum):
    """ErrorDomain

    Describes what the error is related to.
    """

    PLUGIN = 1
    LOAD = 2
    IMPL = 3
    PLATFORM = 4
    SANDBOX = 5
    ARTIFACT = 6
    PIPELINE = 7
    UTIL = 8
    SOURCE = 9
    ELEMENT = 10
    APP = 11
    STREAM = 12
    VIRTUAL_FS = 13
    CAS = 14
    PROG_NOT_FOUND = 15
    REMOTE = 16
    PROFILE = 17


class LoadErrorReason(Enum):
    """LoadErrorReason

    Describes the reason why a :class:`.LoadError` was raised.
    """

    MISSING_FILE = 1
    """A file was not found."""

    INVALID_YAML = 2
    """The parsed data was not valid YAML."""

    INVALID_DATA = 3
    """Data was malformed, a value was not of the expected type, etc"""

    ILLEGAL_COMPOSITE = 4
    """An error occurred during YAML dictionary composition.

    This can happen by overriding a value with a new differently typed
    value, or by overwriting some named value when that was not allowed.
    """

    CIRCULAR_DEPENDENCY = 5
    """A circular dependency chain was detected"""

    UNRESOLVED_VARIABLE = 6
    """A variable could not be resolved. This can happen if your project
    has cyclic dependencies in variable declarations, or, when substituting
    a string which refers to an undefined variable.
    """

    UNSUPPORTED_PROJECT = 7
    """The project requires an incompatible BuildStream version"""

    UNSUPPORTED_PLUGIN = 8
    """Project requires a newer version of a plugin than the one which was
    loaded
    """

    EXPRESSION_FAILED = 9
    """A conditional expression failed to resolve"""

    USER_ASSERTION = 10
    """An assertion was intentionally encoded into project YAML"""

    TRAILING_LIST_DIRECTIVE = 11
    """A list composition directive did not apply to any underlying list"""

    CONFLICTING_JUNCTION = 12
    """Conflicting junctions in subprojects"""

    INVALID_JUNCTION = 13
    """Failure to load a project from a specified junction"""

    SUBPROJECT_INCONSISTENT = 15
    """Subproject has no ref"""

    INVALID_SYMBOL_NAME = 16
    """An invalid symbol name was encountered"""

    MISSING_PROJECT_CONF = 17
    """A project.conf file was missing"""

    LOADING_DIRECTORY = 18
    """Try to load a directory not a yaml file"""

    PROJ_PATH_INVALID = 19
    """A project path leads outside of the project directory"""

    PROJ_PATH_INVALID_KIND = 20
    """A project path points to a file of the not right kind (e.g. a
    socket)
    """

    RECURSIVE_INCLUDE = 21
    """A recursive include has been encountered"""

    CIRCULAR_REFERENCE_VARIABLE = 22
    """A circular variable reference was detected"""

    PROTECTED_VARIABLE_REDEFINED = 23
    """An attempt was made to set the value of a protected variable"""

    INVALID_DEPENDENCY_CONFIG = 24
    """An attempt was made to specify dependency configuration on an element
    which does not support custom dependency configuration"""

    LINK_FORBIDDEN_DEPENDENCIES = 25
    """A link element declared dependencies"""

    CIRCULAR_REFERENCE = 26
    """A circular element reference was detected"""