-
Notifications
You must be signed in to change notification settings - Fork 634
Description
Describe the issue
I am seeing conflicting advice, and would like clarification.
In this repo, ERROR_HANDLING.md, under "Handling service returned errors" [1]:
you can use switches to handle errors based on the error name. instanceof checks are not recommended for error handling due to the possibility of prototype mismatch caused by nesting or other forms of copying/duplication.
But in this AWS Blog, it is all about how we can now use instanceof and implies this is preferable. [2]
In the version 3.53.0 of the modular AWS SDK for JavaScript (v3), we introduced concrete classes for AWS service exceptions which support asserting service exceptions with instanceof operator. In this post, we cover how to use it and how it improves the error handling experience.
Links
[1]
https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/ERROR_HANDLING.md#handling-service-returned-errors
[2]
https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/