Commit 27e029ba authored by Caleb Weeks's avatar Caleb Weeks

adding try / catch to getSling callback function to capture failing model processor output

parent f6ee9e8e
......@@ -186,7 +186,7 @@ SC.getRaw = function(path, callback){
* @param {SlingConnector.slingConnectorCallback} callback
* @private
*/
SC.getSling = function(path, options = {}, callback){
SC.getSling = async function(path, options = {}, callback){
//setup initial params
var sc_self=this;
if(typeof options === "function"){
......@@ -208,6 +208,17 @@ SC.getSling = function(path, options = {}, callback){
})
}
//wrap the callback in a try / catch safe function
const actualCb = callback;
callback = (err, data) => {
try{
actualCb(err, data);
}catch(cbErr){
errorLog("The callback for getSling has an uncaught exception", cbErr);
}
}
if(!this.isValidPath(path)){
callback("invalid path provided");
return;
......@@ -239,11 +250,16 @@ SC.getSling = function(path, options = {}, callback){
path=preprocess.path;
if(sc_self.inMemoryCache && !options.inMemoryCacheRefresh){
// if this path hasn't already been requested, stick the promise verision of it
// if this path hasn't already been requested, stick the promise version of it
// in the cache.
sc_self.inMemoryCache[path] = sc_self.inMemoryCache[path] || sc_self.getSling(path, {...options, inMemoryCacheRefresh: true});
sc_self.inMemoryCache[path].then( data => callback(null, data), err => callback(err) );
try{
let data = await sc_self.inMemoryCache[path];
callback(null, data);
} catch(err){
callback(err);
}
}else{
if(preprocess.proxy){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment