From 45733b30ef8e3fcc7c814fa53cdd392f7cacf50a Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 27 Jul 2021 10:59:24 +0200 Subject: [PATCH] Improved error handling --- src/cpl_query/_query/contains_query.py | 11 +++++++++-- src/cpl_query/exceptions.py | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cpl_query/_query/contains_query.py b/src/cpl_query/_query/contains_query.py index e235c65d..47d29dc8 100644 --- a/src/cpl_query/_query/contains_query.py +++ b/src/cpl_query/_query/contains_query.py @@ -1,5 +1,12 @@ +from cpl_query.exceptions import ArgumentNoneException, ExceptionArgument from cpl_query.extension.iterable_abc import IterableABC -def contains_query(_list: IterableABC, value: object) -> bool: - return value in _list +def contains_query(_list: IterableABC, _value: object) -> bool: + if _list is None: + raise ArgumentNoneException(ExceptionArgument.list) + + if _value is None: + raise ArgumentNoneException(ExceptionArgument.value) + + return _value in _list diff --git a/src/cpl_query/exceptions.py b/src/cpl_query/exceptions.py index b0a320ea..c9694221 100644 --- a/src/cpl_query/exceptions.py +++ b/src/cpl_query/exceptions.py @@ -6,6 +6,7 @@ class ExceptionArgument(Enum): list = 'list' func = 'func' type = 'type' + value = 'value' # exceptions