diafygi / webcrypto-examples

Web Cryptography API Examples Demo: https://diafygi.github.io/webcrypto-examples/
GNU General Public License v2.0
1.64k stars 194 forks source link

Catch top-level exceptions as well #40

Open lionello opened 7 years ago

lionello commented 7 years ago

This will catch (synchronous) exceptions that are thrown at the top-level, by wrapping every call in a promise.

I used the following regex:

([^=].\n                        )(window\.crypto\.subtle\.[^<]+?)(\n                        \.then)
\1Promise.resolve().then(function(){\n                            return \2;\n                        })\3