MCPcopy Create free account
hub / github.com/Snapchat/Valdi / checkErrors

Function checkErrors

compiler/companion/src/native/CompileNativeCommand.ts:13–27  ·  view source on GitHub ↗
(sourceFile: ts.SourceFile, diagnostics: Diagnostic[])

Source from the content-addressed store, hash-verified

11import { NativeCompilerOptions } from './NativeCompilerOptions';
12
13function checkErrors(sourceFile: ts.SourceFile, diagnostics: Diagnostic[]) {
14 for (const diagnostic of diagnostics) {
15 if (diagnostic.category === 'error') {
16 const diagnosticStart = diagnostic.start!;
17 const errorPosition = sourceFile.getPositionOfLineAndCharacter(diagnosticStart.line - 1, diagnosticStart.offset);
18 const fullText = sourceFile.getFullText();
19 const sourceError = fullText.substring(errorPosition, Math.min(errorPosition + 50, fullText.length)).trim();
20 throw Error(
21 `TypeScript Error: ${diagnostic.text.trim()}\nAt line ${diagnostic.start?.line} and column ${
22 diagnostic.start?.offset
23 }:\n${sourceError}`,
24 );
25 }
26 }
27}
28
29class CancelationTokenImpl implements ts.CancellationToken {
30 private cancelled = false;

Callers 1

compileFileFunction · 0.85

Calls 3

substringMethod · 0.80
ErrorInterface · 0.50
trimMethod · 0.45

Tested by

no test coverage detected