Facebook Engineering Blog
Under the Hood: The JavaScript SDK – error handling

Under the Hood: The JavaScript SDK – error handling

11/1/2012 · Øyvind Sean Kinsey

What this post added

This post details the implementation of advanced error handling within Meta's JavaScript SDK. It introduces a `guard` function to wrap arbitrary functions, catching and logging unmanaged errors while re-throwing custom `ManagedError` types. The post also covers techniques for instrumenting entry points like `setTimeout`, event handlers, and callbacks, as well as handling errors in external function invocations and returned functions. A strategy for differentiating internal and external callers to avoid redundant error logging and prevent monkey-patching side effects is also presented.

Read the original post ↗