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


TypeScript loglevel.error函數代碼示例

本文整理匯總了TypeScript中loglevel.error函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript error函數的具體用法?TypeScript error怎麽用?TypeScript error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了error函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: onChange

// error handling taken from https://webpack.github.io/docs/node.js-api.html#error-handling
function onChange(err, stats, livereloadServer, onChangeSuccess?) {
  if (err) {
    // "hard" error
    return error(err);
  }

  if (stats.hasErrors()) {
    // "soft" error
    return error(stats.toString(statsStringifierOptions));
  }

  if (stats.hasWarnings()) {
    warn(stats.toString(statsStringifierOptions));
  }

  // filter changes for live reloading
  const changedModules = stats.compilation.modules.filter(module => module.built && module.resource);
  const changedStyleModules = changedModules.filter(module => module.resource.match(/\.(css|less|sass)$/));
  let hasOnlyStyleChanges = changedModules.length === changedStyleModules.length;
  if (hasOnlyStyleChanges) {
    livereloadServer.refresh('style.css');
  } else {
    livereloadServer.refresh('index.html');
  }

  if (onChangeSuccess) {
    onChangeSuccess(stats);
  }
}
開發者ID:Mercateo,項目名稱:typedocs,代碼行數:30,代碼來源:index.ts

示例2: handleError

export function handleError(err: Error) {
  if (err.stack) {
    err.stack.split('\n')
      .filter(line => !IGNORED_TRACE_LINES.some(ignoredLine => line.includes(ignoredLine)))
      .forEach(line => error(line));
  } else {
    error(err);
  }

  error(`${red('error!')} ( ╯°□°)╯ ┻━━┻`);
  process.exit(1);
}
開發者ID:Mercateo,項目名稱:typedocs,代碼行數:12,代碼來源:error.ts

示例3: onChange

// error handling taken from https://webpack.github.io/docs/node.js-api.html#error-handling
async function onChange(
  err: any,
  stats: compiler.Stats,
  livereloadServer: Server,
  onChangeSuccess?: any
) {
  if (err) {
    // "hard" error
    return error(err);
  }

  if (stats.hasErrors()) {
    // "soft" error
    return error(stringifyStats(stats));
  }

  if (stats.hasWarnings()) {
    warn(stringifyStats(stats));
  }

  if (isVerbose()) {
    info(stringifyStats(stats));
  }

  if (onChangeSuccess) {
    await onChangeSuccess(stats);
  }

  // filter changes for live reloading
  const modules = getModules(stats);
  const changedModules = modules.filter(
    module => module.built && module.resource
  );
  const changedStyleModules = changedModules.filter(module =>
    module.resource.match(/\.(css|less|sass)$/)
  );
  const hasOnlyStyleChanges =
    changedModules.length === changedStyleModules.length;
  if (hasOnlyStyleChanges) {
    livereloadServer.refresh('style.css');
  } else {
    livereloadServer.refresh('index.html');
  }
}
開發者ID:otbe,項目名稱:ws,代碼行數:45,代碼來源:compiler.ts

示例4: lint

export default async function lint() {
  // typescript
  const typescriptFileFailures = await lintAsync();
  if (typescriptFileFailures.length) {
    // log all failures with some basic formatting
    error('');
    for (const fileFailure of typescriptFileFailures) {
      error(`Found ${yellow(fileFailure.failureCount.toString())} failure(s) in ${yellow(fileFailure.failures[0].getFileName())}:`);
      for (const failure of fileFailure.failures) {
        const fileName = failure.getFileName();
        if (!sourceFileLines[fileName]) {
          // attention: sourceFile is a private property!
          sourceFileLines[fileName] = (failure as any).sourceFile.text.split('\n');
        }
        const lines = sourceFileLines[fileName];

        const { line, character } = failure.getStartPosition().getLineAndCharacter();
        error(`  ${failure.getFailure()} ${grey(`(at [${line + 1}:${character + 1}]: ${lines[line].trim()})`)}`);

      }
      error('');
    }
  }

  // documentation
  const documentationFailures = [];
  if (!project.private) {
    if (!(await existsAsync(join(process.cwd(), 'README.md')))) {
      documentationFailures.push(`You have ${yellow('no README.md')}.`);
    }
    if (!project.keywords || !project.keywords.length) {
      documentationFailures.push(`You have ${yellow('no keywords')} set in your ${yellow('package.json')}.`);
    }
    if (!(await existsAsync(join(process.cwd(), 'examples')))) {
      documentationFailures.push(`You have ${yellow('no examples/')} directory.`);
    } else {
      const contents = (await readdirAsync(join(process.cwd(), 'examples'))).filter(content => content !== '.DS_Store');
      if (!contents.length) {
        documentationFailures.push(`Your ${yellow('examples/')} directory ${yellow('is empty')}.`);
      }
    }
  }
  if (documentationFailures.length) {
    error('');
    error(`You're project ${yellow(`isn't private`)}, but it has ${yellow(documentationFailures.length.toString())} documentation failure(s).`);
    documentationFailures.forEach(msg => error(`  ${msg}`));
    error('');
  }

  if (typescriptFileFailures.length || documentationFailures.length) {
    throw `${cyan('lint')} failed.`;
  }
};
開發者ID:Mercateo,項目名稱:typedocs,代碼行數:53,代碼來源:lint.ts

示例5: handleError

export function handleError(err: Error) {
  if (err.stack) {
    err.stack
      .split('\n')
      .filter(
        line =>
          !IGNORED_TRACE_LINES.some(ignoredLine => line.includes(ignoredLine))
      )
      .filter((_, index) => index < 6) // roughly error message + 5 code lines
      .map(line => line.replace('webpack:///', './'))
      .map(line => line.replace(`${__dirname}/webpack:/`, './'))
      .forEach(line => error(line));
  } else {
    error(err);
  }

  error(`${red('error!')} ( ╯°□°)╯ ┻━━┻`);
  process.exitCode = 1;
  // call process.exit with a slight delay to reduce risk of trimmed error logs
  // (e.g. if you call process.exit directly there is a change that some
  // console.log's aren't printed to the console - but we *want* to process.exit,
  // because some commands create server/background tasks which aren't closed otherwise)
  setTimeout(process.exit, 1);
}
開發者ID:otbe,項目名稱:ws,代碼行數:24,代碼來源:error.ts

示例6: format

    filePaths.map(async (filePath, index) => {
      const content = contents[index];
      let formattedContent;

      try {
        formattedContent = format(content, options);
      } catch (err) {
        error(`Couldn't format ${red(filePath)}.`);
        throw err;
      }

      if (content !== formattedContent) {
        fixedFiles.push(filePath);
        await writeFileAsync(filePath, formattedContent);
      }
    })
開發者ID:otbe,項目名稱:ws,代碼行數:16,代碼來源:prettier.ts

示例7: template

function template():string {
  switch (PlatformTools.getTargetPlatforrm()) {
    case TargetPlatformId.IONIC:
      return `
<ion-list>
  <form>
    <ion-list-header>
      Start New Game
    </ion-list-header>
    <ion-item>
      <ion-label for="password">Password (optional):</ion-label>
      <ion-input class="form-control" [(ngModel)]="password" type="text" id="password"></ion-input>
    </ion-item>
    <ion-item>
      <button large block (click)="newGame()">
        Start Game
      </button>
    </ion-item>
  </form>
</ion-list>
`;
    case TargetPlatformId.TWBS_CORDOVA:
    case TargetPlatformId.TWBS_WEB:
      return `
<div>
  <form>
    <div class="panel-heading">
      <h2 class="panel-title">Start New Game</h2>
    </div>
    <div class="panel-body">
      <div class="form-group">
        <label for="password">Password (optional):</label>
        <input class="form-control" [(ngModel)]="password" name="password" type="text" id="password">
      </div>
      <button type="button" class="btn btn-success btn-block" (click)="newGame()">
        Start Game
      </button>
      </div>
  </form>
</div>
`;
    default:
      log.error('Styling not developed for target platform')
  }
}
開發者ID:kokokenada,項目名稱:for-real-cards,代碼行數:45,代碼來源:new-game.ts

示例8: logError

export function logError(msg: string, ...otherArgs: any[]) {
    return log.error(`Error: ${msg}`, ...otherArgs)
}
開發者ID:sigmacloud,項目名稱:rest-resource-vue-tools,代碼行數:3,代碼來源:index.ts

示例9: error

 .forEach(line => error(line));
開發者ID:Mercateo,項目名稱:typedocs,代碼行數:1,代碼來源:error.ts

示例10: error

 documentationFailures.forEach(msg => error(`  ${msg}`));
開發者ID:Mercateo,項目名稱:typedocs,代碼行數:1,代碼來源:lint.ts


注:本文中的loglevel.error函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。