Skip to content
Snippets Groups Projects
Commit 7d05e02f authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

ENH: Add string representation for ImpossibleMergeError

parent 58645183
No related branches found
No related tags found
2 merge requests!184Release 0.9.1,!183F improve error messages
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
from typing import Any
class ForbiddenTransaction(Exception): class ForbiddenTransaction(Exception):
"""Thrown if an transactions is needed that is not allowed. """Thrown if an transactions is needed that is not allowed.
For example an update of an entity if the security level is INSERT For example an update of an entity if the security level is INSERT
...@@ -30,12 +33,40 @@ class ForbiddenTransaction(Exception): ...@@ -30,12 +33,40 @@ class ForbiddenTransaction(Exception):
class ImpossibleMergeError(Exception): class ImpossibleMergeError(Exception):
"""Thrown if due to identifying information, two SyncNodes or two Properties of SyncNodes """Thrown if due to identifying information, two SyncNodes or two Properties of SyncNodes
should be merged, but there is conflicting information that prevents this. should be merged, but there is conflicting information that prevents this.
Parameters
----------
msg : str
A case-specific error message describing where the merger error occurred.
pname : str
The name of the property the values of which caused the merge error.
value_a, value_b : Any
The two values that couldn't be merged.
Attributes
----------
message : str
A case-specific error message describing where the merger error occurred.
values : tuple[Any]
The two values that couldn't be merged.
pname : str
The name of the property the values of which caused the merge error.
""" """
def __init__(self, *args, pname, values, **kwargs): def __init__(self, msg: str, pname: str, value_a: Any, value_b: Any):
self.pname = pname self.pname = pname
self.values = values self.values = (value_a, value_b)
super().__init__(self, *args, **kwargs) self.message = msg
super().__init__(self, msg)
def __str__(self):
return (
f"{self.message}\n\nThe problematic property is '{self.pname}' with "
f"values '{self.values[0]}' and '{self.values[1]}'."
)
def __repr__(self):
return self.__str__()
class InvalidIdentifiableYAML(Exception): class InvalidIdentifiableYAML(Exception):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment