Coverage for src / mafw / mafw_errors.py: 97%
70 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-30 16:10 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-30 16:10 +0000
1# Copyright 2025–2026 European Union
2# Author: Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu)
3# SPDX-License-Identifier: EUPL-1.2
4"""
5Module defines MAFw exceptions
6"""
9class MAFwException(Exception):
10 """Base class for MAFwException"""
12 pass
15class ProcessorParameterError(MAFwException):
16 """Error with a processor parameter"""
18 pass
21class InvalidConfigurationError(MAFwException):
22 """Error with the configuration of a processor"""
24 pass
27class MissingOverloadedMethod(UserWarning):
28 """
29 Warning issued when the user did not overload a required method.
31 It is a warning and not an error because the execution framework might still work, but the results might be
32 different from what is expected.
33 """
35 pass
38class MissingSuperCall(UserWarning):
39 """
40 Warning issued when the user did not invoke the super method for some specific processor methods.
42 Those methods (like :meth:`~mafw.processor.Processor.start` and :meth:`~mafw.processor.Processor.finish`) have not
43 empty implementation also in the base class, meaning that if the user forgets to call *super* in their overloads,
44 then the basic implementation will be gone.
46 It is a warning and not an error because the execution framework might sill work, but the results might be
47 different from what is expected.
48 """
50 pass
53class AbortProcessorException(MAFwException):
54 """Exception raised during the execution of a processor requiring immediate exit."""
56 pass
59class RunnerNotInitialized(MAFwException):
60 """Exception raised when attempting to run a not initialized Runner."""
62 pass
65class InvalidSteeringFile(MAFwException):
66 """Exception raised when validating an invalid steering file"""
68 pass
71class ValidationIssue(InvalidSteeringFile):
72 """Base class for steering validation issues."""
74 def __init__(self, message: str) -> None:
75 super().__init__(message)
78class MissingProcessorsToRunIssue(ValidationIssue):
79 """Issue raised when the steering file does not declare ``processors_to_run``."""
81 def __init__(self) -> None:
82 super().__init__('Missing processors_to_run')
85class ProcessorsToRunNotListIssue(ValidationIssue):
86 """Issue raised when ``processors_to_run`` is not a list."""
88 def __init__(self) -> None:
89 super().__init__('processors_to_run must be a list')
92class MissingUserInterfaceSectionIssue(ValidationIssue):
93 """Issue raised when the ``UserInterface`` section is missing."""
95 def __init__(self) -> None:
96 super().__init__('Missing UserInterface section')
99class UnknownProcessorsToRunEntryIssue(ValidationIssue):
100 """Issue raised when a processor reference in ``processors_to_run`` cannot be resolved."""
102 def __init__(self, entry: str) -> None:
103 super().__init__(f'Processor reference {entry} not defined')
106class UnknownGroupMemberIssue(ValidationIssue):
107 """Issue raised when a group references an unknown processor or nested group."""
109 def __init__(self, group: str, member: str) -> None:
110 super().__init__(f"Group '{group}' references unknown processor or group '{member}'")
113class DuplicateReplicaIssue(ValidationIssue):
114 """Issue raised when a processor declares duplicate replica identifiers."""
116 def __init__(self, base: str, replica: str) -> None:
117 super().__init__(f"Duplicate replica identifier '{replica}' for processor '{base}'")
120class CyclicGroupIssue(ValidationIssue):
121 """Issue raised when cyclic dependencies exist within processor groups."""
123 def __init__(self, node: str) -> None:
124 super().__init__(f"Cyclic group dependency detected at '{node}'")
127class InvalidFilterConditionIssue(ValidationIssue):
128 """Issue raised when a filter condition is incomplete or invalid."""
130 def __init__(
131 self,
132 processor: str,
133 model: str,
134 condition: str,
135 *,
136 field_name: str | None = None,
137 reason: str | None = None,
138 ) -> None:
139 descriptor = f"Condition '{condition}' for model '{model}' in processor '{processor}'"
140 if field_name:
141 descriptor += f" field '{field_name}'"
142 descriptor += ' is invalid'
143 if reason: 143 ↛ 145line 143 didn't jump to line 145 because the condition on line 143 was always true
144 descriptor += f': {reason}'
145 super().__init__(descriptor)
148class InvalidFilterLogicIssue(ValidationIssue):
149 """Issue raised when a filter logic expression is invalid."""
151 def __init__(self, processor: str, target: str, *, detail: str | None = None) -> None:
152 descriptor = f"Logic expression for {target} on processor '{processor}' is invalid"
153 if detail: 153 ↛ 155line 153 didn't jump to line 155 because the condition on line 153 was always true
154 descriptor += f': {detail}'
155 super().__init__(descriptor)
158class UnknownProcessor(MAFwException):
159 """Exception raised when an attempt is made to create an unknown processor"""
161 pass
164class UnknownProcessorGroup(MAFwException):
165 """Exception raised when an attempt is made to create an unknown processor group"""
167 pass
170class UnknownDBEngine(MAFwException):
171 """Exception raised when the user provided an unknown db engine"""
173 pass
176class MissingDatabase(MAFwException):
177 """Exception raised when a processor requiring a database connection is being operated without a database"""
180class MissingAttribute(MAFwException):
181 """Exception raised when an attempt is made to execute a statement without a required parameter/attributes"""
184class ParserConfigurationError(MAFwException):
185 """Exception raised when an error occurred during the configuration of a filename parser"""
188class ParsingError(MAFwException):
189 """Exception raised when a regular expression parsing failed"""
192class MissingSQLStatement(MAFwException):
193 """Exception raised when a Trigger is created without any SQL statements."""
196class UnsupportedDatabaseError(Exception):
197 """Error raised when a feature is not supported by the database."""
200class ModelError(MAFwException):
201 """Exception raised when an error in a DB Model class occurs"""
204class MissingOptionalDependency(UserWarning):
205 """UserWarning raised when an optional dependency is required"""
208class PlotterMixinNotInitialized(MAFwException):
209 """Exception raised when a plotter mixin has not properly initialized"""