Skip to content

Commit

Permalink
feat(bc): add new exception for incoherent matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Jan 4, 2024
1 parent 151765a commit 339c932
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions antarest/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ def __init__(self, message: str) -> None:
super().__init__(HTTPStatus.BAD_REQUEST, message)


class IncoherentConstraintMatrixTerm(HTTPException):
def __init__(self, message: str) -> None:
super().__init__(HTTPStatus.BAD_REQUEST, message)


class MissingDataError(HTTPException):
def __init__(self, message: str) -> None:
super().__init__(HTTPStatus.NOT_FOUND, message)
Expand Down
7 changes: 5 additions & 2 deletions antarest/study/business/binding_constraint_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ConstraintAlreadyExistError,
ConstraintIdNotFoundError,
DuplicateConstraintName,
IncoherentConstraintMatrixTerm,
InvalidConstraintName,
MissingDataError,
NoBindingConstraintError,
Expand Down Expand Up @@ -191,9 +192,11 @@ def create_binding_constraint(

if int(study.version) >= 870:
if data.values is not None:
raise ValueError("You cannot fill 'values' as it refers to the matrix before v8.7")
raise IncoherentConstraintMatrixTerm("You cannot fill 'values' as it refers to the matrix before v8.7")
elif any([data.equal_term_matrix, data.less_term_matrix, data.greater_term_matrix]):
raise ValueError("You cannot fill a 'matrix_term' as these values refer to v8.7+ studies")
raise IncoherentConstraintMatrixTerm(
"You cannot fill a 'matrix_term' as these values refer to v8.7+ studies"
)

command = CreateBindingConstraint(
name=data.name,
Expand Down

0 comments on commit 339c932

Please sign in to comment.