ajvincent / es-membrane

An ECMAScript implementation of a Membrane, allowing users to dynamically hide, override, or extend objects in JavaScript with controlled effects on the original objects.
ISC License
109 stars 13 forks source link

Introduce Membrane.exceptionManager for different types of exceptions #198

Open ajvincent opened 5 years ago

ajvincent commented 5 years ago

Exceptions are a big undefined problem for Membranes. There are several categories of errors:

  1. Errors thrown from one graph's objects to another
  2. Errors thrown from one Membrane through another
  3. Membrane-internal errors
  4. Validation errors on Membrane API's
  5. JavaScript engine invariants on Proxy objects

This last one we never want to see, particularly since we can't do anything about them after they happen. (Ideally, we'd convert them to internal errors first.)

There's also how to report errors of this kind. Generally speaking, I believe exceptions should not be interfered with except to possibly hide details of foreign object graphs (#25) or the Membrane itself. An observer pattern implemented through Membrane.exceptionManager, probably feeding a log4j-like API, would be helpful.

All of this means a special part of the Membrane API that can't be safely folded into Membrane or Membrane.modifyRules.

Finally, we have to distinguish each type of error from the others above.

ajvincent commented 4 years ago

See https://github.com/caridy/secure-javascript-environment/issues/48