diff --git a/cads_adaptors/exceptions.py b/cads_adaptors/exceptions.py index 25be5e40..5cf2cb67 100644 --- a/cads_adaptors/exceptions.py +++ b/cads_adaptors/exceptions.py @@ -12,25 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -from copy import deepcopy - class ParameterError(TypeError): """Raised when a request parameter is invalid.""" -class InvalidRequest(Exception): +class InvalidRequest(ValueError): """Raised when an invalid request is sent to the adaptor.""" - def __init__(self, msgs: None | str | list[str] = None): - if isinstance(msgs, str): - msgs = [msgs] - - if msgs is not None: - super().__init__("\n".join(msgs)) - - self.messages = deepcopy(msgs) - class MarsRuntimeError(RuntimeError): """Raised when a MARS request fails.""" diff --git a/cads_adaptors/validation/enforce.py b/cads_adaptors/validation/enforce.py index 413057bb..8458eaf4 100644 --- a/cads_adaptors/validation/enforce.py +++ b/cads_adaptors/validation/enforce.py @@ -87,7 +87,8 @@ def enforce( for msg in [error_message(e) for e in errors]: if msg not in msgs: msgs.append(msg) - raise cads_adaptors.exceptions.InvalidRequest(msgs) + error_msg = "\n".join(msgs) + raise cads_adaptors.exceptions.InvalidRequest(error_msg) return request