OscarGodson/EpicEditor — pull request #118 by OscarGodson (2012-05-23 06:10:07+00:00)
Title: Better error handling

**THIS IS NOT FINISHED SO DON'T PULL IT IN!**

It's failing an unload test and not really all that tested by me. I just wanted to get a discussion going about if the following is even an issue or not. I feel it is, but don't have a good idea on how to fix it.

Let's say there's a parser error and you catch them like this:

```javascript
var ee = new EpicEditor().load();
ee.on('error', function (err) {
if (err.type == 'invalid_parser') {
console.log('Parser is a broken because '+ err.message);
}
});
```

You see the issue? Me either really aside from just knowing why this wont work because I wrote all the code for EE. The problem is the parser error already happened because `load()` was already called therefore the console log will never get logged like this even with a broken parser. You'd need to change it to:

```javascript
var ee = new EpicEditor();
ee.on('error', function (err) {
if (err.type == 'invalid_parser') {
console.log('Parser is a broken because '+ err.message);
}
});
ee.load();
```

It's not very intuitive tho. Not sure how to fix this or if it's event possible. Ideas? Is this even a real issue or should we explain that you should only put `load()` once _everything_ in EE is setup?

cc: @johnmdonahue