File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
aws_lambda_powertools/utilities/parser Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -171,8 +171,12 @@ def handler(event: Order, context: LambdaContext):
171171 try :
172172 logger .debug (f"Parsing and validating event model with envelope={ envelope } " )
173173 return envelope ().parse (data = event , model = model )
174- except AttributeError :
175- raise InvalidEnvelopeError (f"Envelope must implement BaseEnvelope, envelope={ envelope } " )
174+ except AttributeError as exc :
175+ raise InvalidEnvelopeError (
176+ f"Error: { str (exc )} . Please ensure that both the Input model and the Envelope inherits from BaseModel,\n " # noqa E501
177+ "and your payload adheres to the specified Input model structure.\n "
178+ f"Envelope={ envelope } \n Model={ model } " ,
179+ )
176180
177181 try :
178182 disable_pydantic_v2_warning ()
@@ -181,5 +185,9 @@ def handler(event: Order, context: LambdaContext):
181185 return model .parse_raw (event )
182186
183187 return model .parse_obj (event )
184- except AttributeError :
185- raise InvalidModelTypeError (f"Input model must implement BaseModel, model={ model } " )
188+ except AttributeError as exc :
189+ raise InvalidModelTypeError (
190+ f"Error: { str (exc )} . Please ensure the Input model inherits from BaseModel,\n "
191+ "and your payload adheres to the specified Input model structure.\n "
192+ f"Model={ model } " ,
193+ )
You can’t perform that action at this time.
0 commit comments