OpenF2 / F2

Redefining web integration for the financial services community
Apache License 2.0
130 stars 62 forks source link

Add robust exceptions #162

Open montlebalm opened 10 years ago

montlebalm commented 10 years ago

I've been thinking it could be really helpful to add very expressive and robust exceptions when something goes wrong in F2. Here's an example:

Error: "TypeError: undefined is not a function."
Explanation: "F2 was unable to load the AppClass for 'com_example_foo'."
Solution: "Make sure the script containing the AppClass is included and that the AMD module returns the AppClass function."

In a sense, the library's exceptions can be like a tutorial that guides users into the Pit of Success. We'll give them the actual error, what we were doing that caused it, and how we think it might be solved. We can also include links to relevant documentation that could point the user in the right direction.

These could be enabled all the time or through a DEBUG mode.

markhealey commented 10 years ago

Good thinking @montlebalm. This'd be a good addition to the lib! Extending what you have, I personally like the feature in RequireJS that points you to the docs with further explanation on what went wrong. Example url included in common error with context: http://requirejs.org/docs/errors.html#notloaded