Skip to content

Commit

Permalink
feat(declarative): add detailed error handling and logging
Browse files Browse the repository at this point in the history
Signed-off-by: GLVS Kiriti <[email protected]>
  • Loading branch information
GLVSKiriti committed Jun 17, 2024
1 parent 44cd4af commit fbf1e9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import (
func parseYamlFile(filepath string) (declarative.Tests, error) {
data, err := os.ReadFile(filepath)
if err != nil {
return declarative.Tests{}, err
return declarative.Tests{}, fmt.Errorf("an error occurred while parsing file %s: %w", filepath, err)
}
var tests declarative.Tests
err = yaml.Unmarshal(data, &tests)
if err != nil {
return declarative.Tests{}, err
return declarative.Tests{}, fmt.Errorf("an error occurred while unmarshalling yaml data: %w", err)
}
return tests, nil
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/declarative.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ func NewDeclarative() *cobra.Command {

// Print all errors
if len(failedTests) > 0 {
return fmt.Errorf("some tests failed %v", failedTests)
for _, ft := range failedTests {
fmt.Println(ft)
}
return fmt.Errorf("some tests failed, see previous logs")
}

return nil
Expand Down

0 comments on commit fbf1e9f

Please sign in to comment.