How to use the grpc.status.NOT_FOUND function in grpc

To help you get started, we’ve selected a few grpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googlefonts / fontbakery-dashboard / containers / base / javascript / node / apiServices / StorageBrowse.js View on Github external
.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 ... ???
    });
};
github googlefonts / fontbakery-dashboard / containers / base / javascript / node / dispatcher / FamilyPRDispatcherProcess.js View on Github external
_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');
};
github googlefonts / fontbakery-dashboard / containers / base / javascript / node / manifestSources / CSVSpreadsheet.js View on Github external
.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
github googlefonts / fontbakery-dashboard / containers / base / javascript / node / apiServices / StorageDownload.js View on Github external
.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;
     });
};
github googlefonts / fontbakery-dashboard / containers / base / javascript / node / manifestSources / GoogleFonts.js View on Github external
.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);
        });
    }
github googlefonts / fontbakery-dashboard / containers / base / javascript / node / manifestSources / Git.js View on Github external
.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]);