From 177715011e3adc4a9ed5dbaf28c815aa195ce694 Mon Sep 17 00:00:00 2001 From: Kartikay Date: Tue, 18 Feb 2025 21:09:48 +0530 Subject: [PATCH] err with ref Signed-off-by: Kartikay --- pkg/composableschemadsl/compiler/compiler.go | 1 + pkg/composableschemadsl/compiler/translator.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/composableschemadsl/compiler/compiler.go b/pkg/composableschemadsl/compiler/compiler.go index 9c0e10ee88..9d28e3f4f3 100644 --- a/pkg/composableschemadsl/compiler/compiler.go +++ b/pkg/composableschemadsl/compiler/compiler.go @@ -124,6 +124,7 @@ func Compile(schema InputSchema, prefix ObjectPrefixOption, opts ...Option) (*Co globallyVisitedFiles: mapz.NewSet[string](), locallyVisitedFiles: mapz.NewSet[string](), sourceFolder: cfg.sourceFolder, + mapper: mapper, }, root) if err != nil { return nil, err diff --git a/pkg/composableschemadsl/compiler/translator.go b/pkg/composableschemadsl/compiler/translator.go index 3d54598c57..86da263d46 100644 --- a/pkg/composableschemadsl/compiler/translator.go +++ b/pkg/composableschemadsl/compiler/translator.go @@ -763,6 +763,7 @@ type importResolutionContext struct { // find a cycle, even if we're otherwise marking globally visited nodes. locallyVisitedFiles *mapz.Set[string] sourceFolder string + mapper input.PositionMapper } // Takes a parsed schema and recursively translates import syntax and replaces @@ -812,7 +813,7 @@ func translateImports(itctx importResolutionContext, root *dslNode) error { // This is a new node provided by the translateImport parsedImportRoot, err := importFile(filePath) if err != nil { - return err + return toContextError("failed to read import in schema file", "", topLevelNode, itctx.mapper) } // We recurse on that node to resolve any further imports @@ -820,6 +821,7 @@ func translateImports(itctx importResolutionContext, root *dslNode) error { sourceFolder: newSourceFolder, locallyVisitedFiles: currentLocallyVisitedFiles, globallyVisitedFiles: itctx.globallyVisitedFiles, + mapper: itctx.mapper, }, parsedImportRoot) if err != nil { return err