chelm/geohub — pull request #2 by nixta (2013-08-13 17:23:12+00:00)
Title: Refactor slightly to avoid reentrancy in the case of an unhandled error in the callback function

An error in the callback function is caught by the catch() statement in repo() (Line 13) and then the same callback is called once more from the catch() statement (Line 16).
```
var json = JSON.parse( body );
try {
if (json.type && json.type == 'FeatureCollection'){
callback( null, json );
}
} catch (e) {
callback('Error: could not parse file contents' + e, null);
}
```
This leads to very confusing output from the callback and also hides potentially useful crash information when the callback is initially called and errors out. It's also different to the gist function.