salsify / ember-exclaim

An addon allowing apps to expose declarative, JSON-configurable custom UIs backed by Ember components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: onError action

skarger opened this issue · comments

An error that comes up sometimes when defining Exclaim UIs is a $bind referencing a key that does not exist in the given env.

For example, if your declared UI is the following:

        {
          ui: {
            $input: {
              $bind: 'non_existent.some_key',
            },
          },
        };

If you pass an env to {{exclaim-ui}} that does not include non_existent, then there will be an error when the end-user fills in the rendered <input>.

EmberError {stack: "Error: Property set failed: object in path "__env_…t http://localhost:4200/assets/vendor.js:38818:45", description: undefined, fileName: undefined, lineNumber: undefined, message: "Property set failed: object in path "__env__.non_existent" could not be found or was destroyed.", …}

While there may be other ways to mitigate this, the solution proposed here is for {exclaim-ui}} to expose an onError property.

It would be called with at least the raised Error. Maybe there are other useful params too.

Then client code can do something appropriate when that happens, such as rendering a more instructional message in its own UI.

This is a great idea- I'll try tackling this next time I have an open Friday