ghost · GitHub

While digging in to #5364, I noticed a couple of small assumptions that meant the toError method in app/scripts/lib/errors.js doesn't behave sanely for all inputs. They're probably not the cause of the [object Object] error messages I'm looking in to, but maybe they're still worth plugging?

The first one is that find (called from toErrno) throws when searchFor is undefined or null.

The second is that toError assumes toMessage will always return a string but the doc comment says it can return a string or an error object, although I couldn't find a reasonable way to make that happen from the tests, so maybe the comment is out of date. But if you look at the implementation there, you'll notice it doesn't check the type of err.forceMessage or err.message before returning, so it seems possible that we might end up doing the equivalent of a new Error({}) back inside toError, which does produce the [object Object] error message.

Anyway, I'll leave it up to you guys to decide whether both, either or neither of them are worth keeping.

@mozilla/fxa-devs r?

Read the original on github.com ↗