MCPcopy Create free account
hub / github.com/TritonDataCenter/node-manta / readError

Function readError

lib/client.js:427–460  ·  view source on GitHub ↗
(err, res, cb)

Source from the content-addressed store, hash-verified

425
426
427function readError(err, res, cb) {
428 assert.object(err);
429 assert.optionalObject(res);
430 assert.func(cb);
431
432 if (res === null)
433 return (cb(null, err, res));
434
435 var body = '';
436 res.setEncoding('utf8');
437 res.on('data', function (chunk) {
438 body += chunk;
439 });
440
441 res.once('end', function () {
442 err._body = body;
443
444 try {
445 err.body = JSON.parse(body);
446 } catch (e) {
447 }
448
449 err.body = err.body || {};
450 err.code = err.body.code;
451 err.message = err.body.message;
452 err.name = err.body.code || err.name;
453 if (!/.*Error$/.test(err.name))
454 err.name += 'Error';
455
456 cb(null, err, res);
457 });
458
459 return (undefined);
460}
461
462
463function resultToInfoCb(_path, cb) {

Callers 2

onResultFunction · 0.85
resultToInfoCbFunction · 0.85

Calls 1

cbFunction · 0.85

Tested by

no test coverage detected