當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript npmlog.error函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。