Skip to content

Commit

Permalink
Revert "clear"
Browse files Browse the repository at this point in the history
This reverts commit f1ac42c.
  • Loading branch information
seyed-dev committed Nov 4, 2023
1 parent f1ac42c commit c9687f0
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions aggify/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@


class AggifyBaseException(Exception):
def __init__(self, message: str):
self.message = message
super().__init__(self.message)
message: str


class MongoIndexError(AggifyBaseException):
def __init__(self):
super().__init__("Index error is invalid, please use int or slice without step!")
self.message = "Index error is invalid, please use int or slice without step!"
super().__init__(self.message)


class InvalidPipelineStageError(AggifyBaseException):
Expand All @@ -18,48 +17,58 @@ class InvalidPipelineStageError(AggifyBaseException):
Subclass and customise for the raised exception in the methods
"""

def __init__(self, message):
self.message = message
super().__init__(self.message)


class AnnotationError(InvalidPipelineStageError):
pass


class OutStageError(InvalidPipelineStageError):
def __init__(self, stage):
super().__init__(f"You cannot add a {stage!r} pipeline after $out stage!")
self.message = f"You cannot add a {self!r} pipeline after $out stage!"
super().__init__(self.message)


class AggifyValueError(AggifyBaseException):
def __init__(self, expected_list: List[Type], result: Type):
super().__init__(
f"Input is not correctly passed, expected either of {expected_list}, but got {result}"
self.message = (
f"Input is not correctly passed, expected either of {[expected for expected in expected_list]}"
f"but got {result}"
)
self.expecteds = expected_list
self.result = result
super().__init__(self.message)


class InvalidOperator(AggifyBaseException):
def __init__(self, operator: str):
super().__init__(
f"Operator {operator} does not exist, please refer to documentation to see all supported operators."
)
self.message = f"Operator {operator} does not exists, please refer to documentation to see all supported operators."
super().__init__(self.message)


class InvalidField(AggifyBaseException):
def __init__(self, field: str):
super().__init__(f"Field {field} does not exist.")
self.message = f"Field {field} does not exists."
super().__init__(self.message)


class InvalidEmbeddedField(AggifyBaseException):
def __init__(self, field: str):
super().__init__(f"Field {field} is not embedded.")
self.message = f"Field {field} is not embedded."
super().__init__(self.message)


class AlreadyExistsField(AggifyBaseException):
def __init__(self, field: str):
super().__init__(f"Field {field} already exists.")
self.message = f"Field {field} already exists."
super().__init__(self.message)


class InvalidArgument(AggifyBaseException):
def __init__(self, expected_list: list):
super().__init__(f"Input is not correctly passed, expected {expected_list}")
self.message = f"Input is not correctly passed, expected {[expected for expected in expected_list]}"
self.expecteds = expected_list
super().__init__(self.message)

0 comments on commit c9687f0

Please sign in to comment.