adlnet / xAPIWrapper

Wrapper to simplify communication to an LRS
https://adlnet.gov/projects/xapi/
Apache License 2.0
219 stars 114 forks source link

XHR callbacks - problems with try/catch #91

Closed webb-nickj closed 7 years ago

webb-nickj commented 7 years ago

The use of try and catch to parse AJAX responses to JSON could currently mask errors in the callback function.

Would better if the callback was handled outside of try/catch:

var callbackData;
try{
    callbackData = JSON.parse( xhr.responseText );
}catch( e ){
    callbackData = xhr.repsonseText;
}

strictCallbacks ? callback(null, xhr, callbackData) : callback(xhr,callbackData);
ajanderson1209 commented 7 years ago

Hey Nick, thanks for the bug information. The pull request is merged and should fix this issue. Thanks!