From 06fc4aaad6b197f635a9cb6c2da6d681e4f5b117 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 7 Jul 2022 08:47:41 -0400 Subject: [PATCH] Common: Catch MarshmallowError instead of Exception --- monkey/common/credentials/credentials.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/monkey/common/credentials/credentials.py b/monkey/common/credentials/credentials.py index 1837fd8b6..732818783 100644 --- a/monkey/common/credentials/credentials.py +++ b/monkey/common/credentials/credentials.py @@ -4,6 +4,7 @@ from dataclasses import dataclass from typing import Any, Mapping, MutableMapping, Sequence, Tuple from marshmallow import Schema, fields, post_load, pre_dump +from marshmallow.exceptions import MarshmallowError from . import ( CredentialComponentType, @@ -122,7 +123,7 @@ class Credentials: return Credentials(**deserialized_data) except (InvalidCredentialsError, InvalidCredentialComponentError) as err: raise err - except Exception as err: + except MarshmallowError as err: raise InvalidCredentialsError(str(err)) @staticmethod @@ -132,7 +133,7 @@ class Credentials: return Credentials(**deserialized_data) except (InvalidCredentialsError, InvalidCredentialComponentError) as err: raise err - except Exception as err: + except MarshmallowError as err: raise InvalidCredentialsError(str(err)) @staticmethod