Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(null, err=> {
// ... 404 not found OR 500 depends on the message!
var statusCode = 500
, message = 'Internal Error'
, requests = this._messageRequests.get(messageId) || []
;
if(err.code === grpcStatus.NOT_FOUND) {
statusCode = 404;
message = 'Not Found: ' + err.details;
}
else
this._log.error('browse storage [GET]', messageId, err);
for(let [res, /*filename*/] of requests)
res.status(statusCode).send(message);
this._messageRequests.delete(messageId);
//if(statusCode === 500)
// should probably clean up directory ... ???
});
};
_p.callbackReceiveFamilyData = function([requester, sessionID]
, familyDataMessage // a FamilyData message
, source, ...continuationArgs) {
// jshint unused:vars
var sourceLabel = source2label(source);
if(familyDataMessage.getStatus() === FamilyData.Result.FAIL) {
if(familyDataMessage.getErrorCode === grpcStatus.NOT_FOUND) {
// Not setting FAILED here as I expect this will happen
// sometimes!
this._setREPORT('Comparison family data **not found** in '
+ `"${sourceLabel}". Try another source?`);
this._expectChooseAction();
}
else {
this._setREPORT('**ERROR** ' + familyDataMessage.getError());
this._setFAILED('Can\'t create comparison family data.');
}
return;
}
return _taskCallDiffWorker.call(this, familyDataMessage
, 'diffenator', 'callbackDiffenatorFinished');
};
.then(null, err=>{
this._log.error(`[_getGitData] Can't get `
+ `entry from path: "${path}"`, err);
// the original error was not helpful at all
var error = new Error('Can\'t get entry from path:'
+ ` \`${path}\`. Is the \`fontfilesPrefix\` correct?`);
error.code = grpcStatus.NOT_FOUND;
error.name = 'NOT_FOUND';
throw error;
})
.then(_getTreeFromTreeEntry) // -> tree
.then(null, err=> {
// ... 404 not found OR 500 depends on the message!
var statusCode = 500
, message = 'Internal Error'
;
if(err.code === grpcStatus.NOT_FOUND) {
statusCode = 404;
message = 'Not Found: ' + err.details;
}
this._log.error('_download storage [GET]', req.params.storage
, req.params.keys_and_names, err);
res.status(statusCode).send(message);
return;
});
};
.then(stream=>{
var { statusCode } = stream;
if (statusCode !== 200) {
var error = new Error(`Request Failed.\nStatus Code: ${statusCode}`
+` at URL: ${fileUrl}`);
if(statusCode === 404) {
error.code = grpcStatus.NOT_FOUND;
error.name = 'NOT_FOUND';
}
throw error;
}
return _dataFromStream(stream);
});
}
.then(([currentCommit, familiesMap])=>{
if(!familiesMap.has(familyName)) {
var error = new Error('No family found for "' + familyName + '".');
error.code = grpcStatus.NOT_FOUND;
error.name = 'NOT_FOUND';
throw error;
}
var path = familiesMap.get(familyName);
return currentCommit.getTree()
.then(tree=>getTreeEntryByPath(tree, path))
.then(treeEntry=>Promise.all([
familyName
, treeEntry.getTree().then(tree=>this._treeToFilesData(tree))
, this._treeEntryToMetadata(currentCommit, treeEntry)
]));
})
.then(([familyName, filesData, metadata])=>[familyName, metadata.targetDirectory, filesData, metadata]);