Skip to content

Instantly share code, notes, and snippets.

@cheeyeo
Created June 23, 2020 15:43
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheeyeo/33a5c321b81ad5403822e468f7e965ec to your computer and use it in GitHub Desktop.
Save cheeyeo/33a5c321b81ad5403822e468f7e965ec to your computer and use it in GitHub Desktop.
Creating a boto3 ClientError manually!
raise ClientError(operation_name='InvalidKeyPair.Duplicate', error_response={
'Error': {
'Code': 'Duplicate',
'Message': 'This is a custom message'
}
}
)
@cheeyeo
Copy link
Author

cheeyeo commented Jun 23, 2020

This is not recommended but rather let the boto3 sdk return the appropriate exceptions

Only use I can think of is you have custom exceptions ...

@cmgg
Copy link

cmgg commented Nov 24, 2022

Thank you, this was really helpful for creating a MagicMock side effect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment