From 233da856335a04fbce226403be0fd63961eaf89b Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Thu, 11 Sep 2025 20:46:59 +0300 Subject: [PATCH] fix(schema-compiler): Pass filename alongside with errors to error reporter during transpilation --- .../src/compiler/DataSchemaCompiler.ts | 12 ++++++------ .../src/compiler/ErrorReporter.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts b/packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts index fcb61b32ac0ba..3094f8d3beca6 100644 --- a/packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts +++ b/packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts @@ -627,7 +627,7 @@ export class DataSchemaCompiler { errorsReport.error(`No transpilation result received for the file ${file.fileName}.`); return undefined; } - errorsReport.addErrors(res[index].errors); + errorsReport.addErrors(res[index].errors, file.fileName); errorsReport.addWarnings(res[index].warnings as unknown as SyntaxErrorInterface[]); errorsReport.exitFile(); @@ -654,7 +654,7 @@ export class DataSchemaCompiler { errorsReport.error(`No transpilation result received for the file ${file.fileName}.`); return undefined; } - errorsReport.addErrors(res[index].errors); + errorsReport.addErrors(res[index].errors, file.fileName); errorsReport.addWarnings(res[index].warnings as unknown as SyntaxErrorInterface[]); errorsReport.exitFile(); @@ -686,7 +686,7 @@ export class DataSchemaCompiler { errorsReport.inFile(file); const res = await transpileJs([reqData]); - errorsReport.addErrors(res[0].errors); + errorsReport.addErrors(res[0].errors, file.fileName); errorsReport.addWarnings(res[0].warnings as unknown as SyntaxErrorInterface[]); errorsReport.exitFile(); @@ -701,7 +701,7 @@ export class DataSchemaCompiler { }; const res = await this.workerPool!.exec('transpileJs', [data]); - errorsReport.addErrors(res.errors); + errorsReport.addErrors(res.errors, file.fileName); errorsReport.addWarnings(res.warnings); return { ...file, content: res.content }; @@ -761,7 +761,7 @@ export class DataSchemaCompiler { errorsReport.inFile(file); const res = await transpileYaml([reqData]); - errorsReport.addErrors(res[0].errors); + errorsReport.addErrors(res[0].errors, file.fileName); errorsReport.addWarnings(res[0].warnings as unknown as SyntaxErrorInterface[]); errorsReport.exitFile(); @@ -778,7 +778,7 @@ export class DataSchemaCompiler { }; const res = await this.workerPool!.exec('transpileYaml', [data]); - errorsReport.addErrors(res.errors); + errorsReport.addErrors(res.errors, file.fileName); errorsReport.addWarnings(res.warnings); this.compiledYamlCache.set(cacheKey, res.content); diff --git a/packages/cubejs-schema-compiler/src/compiler/ErrorReporter.ts b/packages/cubejs-schema-compiler/src/compiler/ErrorReporter.ts index fb5ac95a7b2d0..94b96e278372f 100644 --- a/packages/cubejs-schema-compiler/src/compiler/ErrorReporter.ts +++ b/packages/cubejs-schema-compiler/src/compiler/ErrorReporter.ts @@ -147,8 +147,8 @@ export class ErrorReporter { return this.rootReporter().errors; } - public addErrors(errors: PossibleError[]) { - errors.forEach((e: any) => { this.error(e); }); + public addErrors(errors: PossibleError[], fileName?: string) { + errors.forEach((e: any) => { this.error(e, fileName); }); } public getWarnings() {