本文整理汇总了TypeScript中npmlog.error函数的典型用法代码示例。如果您正苦于以下问题:TypeScript error函数的具体用法?TypeScript error怎么用?TypeScript error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
const returnError = (err, res, req) => {
if (err instanceof ClientError) {
const status = err.code == 'NOT_AUTHORIZED' ? 401 : 400;
if (!opts.disableLogs)
log.info(
'Client Err: ' + status + ' ' + req.url + ' ' + JSON.stringify(err)
);
res
.status(status)
.json({
code: err.code,
message: err.message
})
.end();
} else {
let code = 500,
message;
if (err && ((err.code && _.isNumber(err.code)) || (err.statusCode && _.isNumber(err.statusCode)))) {
code = err.code || err.statusCode;
message = err.message || err.body;
}
const m = message || err.toString();
if (!opts.disableLogs) log.error(req.url + ' :' + code + ':' + m);
res
.status(code || 500)
.json({
error: m
})
.end();
}
};
开发者ID:matiu,项目名称:bitcore,代码行数:35,代码来源:expressapp.ts
示例2: catch
const result = _.mapValues(template, (t) => {
try {
return Mustache.render(t, data);
} catch (e) {
log.error('Could not apply data to template', e);
error = e;
}
});
开发者ID:bitpay,项目名称:bitcore,代码行数:8,代码来源:pushnotificationsservice.ts
示例3: next
this._makeRequest(notification, (err, response) => {
if (err) log.error(err);
if (response) {
log.debug('Request status: ', response.statusCode);
log.debug('Request message: ', response.statusMessage);
log.debug('Request body: ', response.request.body);
}
next();
});
开发者ID:bitpay,项目名称:bitcore,代码行数:9,代码来源:pushnotificationsservice.ts
示例4: create
export function create(name: string) {
if(fs.existsSync(name)) {
log.error(`${name} is already exists`);
process.exit(1);
}
/* template for skeleton */
const hosts: Array<Object> = [{
localhost: {
host: 'localhost',
port: 22,
user: 'root'
}
}];
const waka: Array<Object> = [{
hosts: 'localhost',
tasks: [
{ shell: "say 'めぐりあひて 見しやそれとも わかぬまに 雲がくれにし 夜半の月かな'" }
]
}];
new Promise(resolve => {
fs.mkdir(name, () => {
log.info('create', name);
return resolve();
});
})
.then((): void => {
fs.writeFile(path.resolve(name, 'hosts.yml'), yaml.safeDump(hosts), err => {
if(err) {
throw err;
}
return;
});
})
.then((): void => {
const dirname = path.join(name, 'monogatari');
fs.mkdir(dirname, (): void => {
log.info('create', dirname);
return;
});
})
.then((): void => {
fs.writeFile(path.resolve(name, 'monogatari', 'waka.yml'), yaml.safeDump(waka), err => {
if(err) {
throw err;
}
return;
});
})
.catch(err => {
log.error(err);
});
}
开发者ID:waffle-iron,项目名称:shikibu,代码行数:55,代码来源:create.ts
示例5: cb
(err, db) => {
if (err) {
log.error('Unable to connect to the mongoDB', err);
return cb(err, null);
}
log.info('Connection established to ' + uri);
this.db = db;
this._getStats((err, stats) => {
if (err) return cb(err);
return cb(null, stats);
});
}
开发者ID:bitpay,项目名称:bitcore,代码行数:12,代码来源:stats.ts
示例6: cb
this.storage.fetchPreferences(notification.walletId, null, (
err,
preferences
) => {
if (err) log.error(err);
if (_.isEmpty(preferences)) preferences = [];
const recipientPreferences = _.compact(
_.map(preferences, (p) => {
if (!_.includes(this.availableLanguages, p.language)) {
if (p.language)
log.warn(
'Language for notifications "' +
p.language +
'" not available.'
);
p.language = this.defaultLanguage;
}
return {
copayerId: p.copayerId,
language: p.language,
unit: unit || p.unit || this.defaultUnit
};
})
);
const copayers = _.keyBy(recipientPreferences, 'copayerId');
const recipientsList = _.compact(
_.map(wallet.copayers, (copayer) => {
if (
(copayer.id == notification.creatorId &&
notificationType.notifyCreatorOnly) ||
(copayer.id != notification.creatorId &&
!notificationType.notifyCreatorOnly)
) {
const p = copayers[copayer.id] || {
language: this.defaultLanguage,
unit: this.defaultUnit
};
return {
copayerId: copayer.id,
language: p.language || this.defaultLanguage,
unit: unit || p.unit || this.defaultUnit
};
}
})
);
return cb(null, recipientsList);
});
开发者ID:bitpay,项目名称:bitcore,代码行数:52,代码来源:pushnotificationsservice.ts
示例7: next
this.storage.fetchAddressByCoin(coin, out.address, (
err,
address
) => {
if (err) {
log.error('Could not fetch addresses from the db');
return next(err);
}
if (!address || address.isChange) return next();
const walletId = address.walletId;
log.debug(
'Incoming tx for wallet ' +
walletId +
' [' +
out.amount +
'sat -> ' +
out.address +
']'
);
const fromTs = Date.now() - 24 * 3600 * 1000;
this.storage.fetchNotifications(walletId, null, fromTs, (
err,
notifications
) => {
if (err) return next(err);
const alreadyNotified = _.some(notifications, (n) => {
return (
n.type == 'NewIncomingTx' && n.data && n.data.txid == data.txid
);
});
if (alreadyNotified) {
log.debug(
'The incoming tx ' + data.txid + ' was already notified'
);
return next();
}
const notification = Notification.create({
type: 'NewIncomingTx',
data: {
txid: data.txid,
address: out.address,
amount: out.amount
},
walletId
});
this._storeAndBroadcastNotification(notification, next);
});
});
开发者ID:bitpay,项目名称:bitcore,代码行数:52,代码来源:blockchainmonitor.ts
示例8: cb
.catch(err => {
if (count > 3 ) {
log.error('FINAL Broadcast error:', err);
return cb(err);
} else {
count++;
// retry
setTimeout(() => {
log.info('Retrying broadcast after', count * Defaults.BROADCAST_RETRY_TIME);
return this.broadcast(rawTx, cb, count);
}, count * Defaults.BROADCAST_RETRY_TIME);
}
});
开发者ID:bitpay,项目名称:bitcore,代码行数:13,代码来源:v8.ts
示例9: test
test('request', (t) => {
t.plan(1);
npmlog.level = 'silly';
npmlog.silly('silly prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.verbose('verbose prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.info('info prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.http('http prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.warn('warn prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.error('error prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.silent('silent prefix', 'x = %j', {foo:{bar:'baz'}});
t.deepEqual(result.join('').trim(), resultExpect.join('').trim(), 'result');
});
开发者ID:demurgos,项目名称:typed-npmlog,代码行数:13,代码来源:test.ts
示例10:
expressApp.start(config, (err) => {
if (err) {
log.error('Could not start BWS instance', err);
return;
}
server.listen(port);
const instanceInfo = cluster.worker
? ' [Instance:' + cluster.worker.id + ']'
: '';
log.info('BWS running ' + instanceInfo);
return;
});
开发者ID:bitpay,项目名称:bitcore,代码行数:14,代码来源:bws.ts
注:本文中的npmlog.error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论