From 8e1854228c60e820d2ebacf52bcf535154f34ca5 Mon Sep 17 00:00:00 2001 From: Paul Johnston Date: Mon, 5 Aug 2024 23:28:12 -0600 Subject: [PATCH] Fail fast on parse errors --- pkg/provider/source_provider.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/provider/source_provider.go b/pkg/provider/source_provider.go index 1380e0d..2e9744d 100644 --- a/pkg/provider/source_provider.go +++ b/pkg/provider/source_provider.go @@ -139,9 +139,11 @@ func (r *SourceProvider) parseFiles(dir string, srcs []string) ([]*sppb.File, er return nil, fmt.Errorf("parser error: %s", response.Error) } - // remove dir prefixes + // check for errors and remove dir prefixes for _, file := range response.Files { - // TODO(pcj): isn't there a stdlib function that does this? + if file.Error != "" { + return nil, fmt.Errorf("%s parse error: %s", file.Filename, file.Error) + } file.Filename = strings.TrimPrefix(strings.TrimPrefix(file.Filename, dir), "/") }