diff --git a/mark.go b/mark.go index 91359c8..927994f 100644 --- a/mark.go +++ b/mark.go @@ -102,6 +102,7 @@ func Run(config Config) error { } } + var hasErrors bool for _, file := range files { log.Infof(nil, "processing %s", file) @@ -109,6 +110,7 @@ func Run(config Config) error { if err != nil { if config.ContinueOnError { log.Errorf(err, "processing %s", file) + hasErrors = true continue } return err @@ -122,6 +124,10 @@ func Run(config Config) error { } } + if hasErrors { + return fmt.Errorf("one or more files failed to process") + } + return nil } @@ -300,6 +306,9 @@ func ProcessFile(file string, api *confluence.API, config Config) (*confluence.P if err != nil { return nil, fmt.Errorf("unable to retrieve page by id: %w", err) } + if pg == nil { + return nil, fmt.Errorf("page with id %q not found", config.PageID) + } target = pg } diff --git a/markdown/markdown_test.go b/markdown/markdown_test.go index eb0313e..3f21b7b 100644 --- a/markdown/markdown_test.go +++ b/markdown/markdown_test.go @@ -181,5 +181,8 @@ func TestContinueOnError(t *testing.T) { } err := cmd.Run(context.TODO(), argList) - assert.NoError(t, err, "App should run without errors when continue-on-error is enabled") + // --continue-on-error processes all files even when some fail, but still + // returns an error to allow callers/CI to detect partial failures. + assert.Error(t, err, "App should report partial failure when continue-on-error is enabled and some files fail") + assert.ErrorContains(t, err, "one or more files failed to process") }