Exception System Interoperability
How to translate explicit-exceptions to a different exception system.
You may wish to keep explicit-exceptions as an internal detail to your package, and keep your package users unaware of its use. We recommend creating a helper function that does this translation for you, then applying this helper function to every function you export. The following code snippet shows an example of how one would translate explicit exceptions into a custom Error instance (distinguished by a code property).
index.js
A similar solution can be created if you wish to make a different subclass for each kind of exception instead.
Last updated