Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more information in some errors #255

Merged
merged 1 commit into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/processors/frontmatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package processors

import (
"fmt"
"strings"

"github.com/gardener/docforge/pkg/api"
Expand Down Expand Up @@ -59,7 +60,7 @@ func (f *FrontMatter) Process(document *Document) error {
fmBytes = document.FrontMatter
docFm = map[string]interface{}{}
if err := yaml.Unmarshal(fmBytes, docFm); err != nil {
return err
return fmt.Errorf("failed to unmarsal the document frontmatter. %+v", err)
}

for propertyKey, propertyValue := range docFm {
Expand Down
4 changes: 2 additions & 2 deletions pkg/reactor/document_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ func (w *DocumentWorker) Work(ctx context.Context, task interface{}) error {
doc.Append(documentBytes)
if w.Processor != nil {
if err := w.Processor.Process(doc); err != nil {
return err
return fmt.Errorf("failed to process the document: %s. %+v", doc.Node.Source, err)
}
}
documentBytes = doc.DocumentBytes
if documentBytes, err = markdown.InsertFrontMatter(doc.FrontMatter, documentBytes); err != nil {
return err
return fmt.Errorf("failed to insert frontmatter to document: %s. %+v", doc.Node.Source, err)
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/reactor/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (r *Reactor) Run(ctx context.Context, manifest *api.Documentation, dryRun b
}()

if err := ResolveManifest(ctx, manifest, r.ResourceHandlers, r.manifestAbsPath, r.IndexFileNames); err != nil {
return err
return fmt.Errorf("failed to resolve manifest: %s. %+v", r.manifestAbsPath, err)
}

if err := checkForCollisions(manifest.Structure); err != nil {
Expand Down Expand Up @@ -190,7 +190,7 @@ func addSourceLocation(locations map[string][]*api.Node, node *api.Node) {
func printResolved(ctx context.Context, manifest *api.Documentation, writer io.Writer) error {
s, err := api.Serialize(manifest)
if err != nil {
return err
return fmt.Errorf("failed to serialize the manifest. %+v", err)
}
writer.Write([]byte(s))
writer.Write([]byte("\n\n"))
Expand Down