From 6adba1b43aa72584dd1a728c71479f6203238090 Mon Sep 17 00:00:00 2001 From: Wes Date: Thu, 14 Mar 2024 17:16:10 -0700 Subject: [PATCH] fix: clean up log output for build failures (#1094) --- buildengine/build_go.go | 2 +- buildengine/build_kotlin.go | 2 +- buildengine/engine.go | 1 + cmd/ftl/cmd_dev.go | 2 +- cmd/ftl/cmd_serve.go | 5 +++-- internal/exec/circularbuffer.go | 1 - 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/buildengine/build_go.go b/buildengine/build_go.go index 7bd23c82b1..31f1d31e75 100644 --- a/buildengine/build_go.go +++ b/buildengine/build_go.go @@ -10,7 +10,7 @@ import ( func buildGo(ctx context.Context, sch *schema.Schema, module Module) error { if err := compile.Build(ctx, module.Dir, sch); err != nil { - return fmt.Errorf("failed to build module: %w", err) + return fmt.Errorf("failed to build module %s: %w", module.Module, err) } return nil } diff --git a/buildengine/build_kotlin.go b/buildengine/build_kotlin.go index e7ed704d4d..d23fa2c546 100644 --- a/buildengine/build_kotlin.go +++ b/buildengine/build_kotlin.go @@ -55,7 +55,7 @@ func buildKotlin(ctx context.Context, sch *schema.Schema, module Module) error { logger.Debugf("Using build command '%s'", module.Build) err := exec.Command(ctx, log.Debug, module.Dir, "bash", "-c", module.Build).RunBuffered(ctx) if err != nil { - return fmt.Errorf("failed to build module: %w", err) + return fmt.Errorf("failed to build module %s: %w", module.Module, err) } return nil diff --git a/buildengine/engine.go b/buildengine/engine.go index da4c980581..f1f843a4ea 100644 --- a/buildengine/engine.go +++ b/buildengine/engine.go @@ -429,6 +429,7 @@ func (e *Engine) build(ctx context.Context, name string, built map[string]*schem module := e.modules[name] err := Build(ctx, sch, module) if err != nil { + return err } moduleSchema, err := schema.ModuleFromProtoFile(filepath.Join(module.Dir, module.DeployDir, module.Schema)) diff --git a/cmd/ftl/cmd_dev.go b/cmd/ftl/cmd_dev.go index a413fc8383..024c0d1c41 100644 --- a/cmd/ftl/cmd_dev.go +++ b/cmd/ftl/cmd_dev.go @@ -34,7 +34,7 @@ func (d *devCmd) Run(ctx context.Context) error { d.ServeCmd.Stop = false } if d.ServeCmd.isRunning(ctx, client) { - return errors.New("FTL is already running") + return errors.New(ftlRunningErrorMsg) } g.Go(func() error { diff --git a/cmd/ftl/cmd_serve.go b/cmd/ftl/cmd_serve.go index 8459bc36d7..3f68d71644 100644 --- a/cmd/ftl/cmd_serve.go +++ b/cmd/ftl/cmd_serve.go @@ -44,6 +44,7 @@ type serveCmd struct { } const ftlContainerName = "ftl-db-1" +const ftlRunningErrorMsg = "FTL is already running. Use 'ftl serve --stop' to stop it" func (s *serveCmd) Run(ctx context.Context) error { logger := log.FromContext(ctx) @@ -71,7 +72,7 @@ func (s *serveCmd) Run(ctx context.Context) error { } if s.isRunning(ctx, client) { - return errors.New("FTL is already running") + return errors.New(ftlRunningErrorMsg) } logger.Infof("Starting FTL with %d controller(s)", s.Controllers) @@ -131,7 +132,7 @@ func (s *serveCmd) Run(ctx context.Context) error { func runInBackground(logger *log.Logger) { if running, _ := isServeRunning(logger); running { - logger.Warnf("'ftl serve' is already running in the background. Use --stop to stop it.") + logger.Warnf(ftlRunningErrorMsg) return } diff --git a/internal/exec/circularbuffer.go b/internal/exec/circularbuffer.go index 18d4e7ea7a..f379fc1c6b 100644 --- a/internal/exec/circularbuffer.go +++ b/internal/exec/circularbuffer.go @@ -48,7 +48,6 @@ func (cb *CircularBuffer) Bytes() []byte { defer cb.mu.Unlock() if cb.size == 0 { - fmt.Println("Buffer is empty.") return []byte{} }