本文整理汇总了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;未经允许,请勿转载。 |
请发表评论