Skip to content

Commit

Permalink
Improve error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestEckhardt committed Sep 10, 2024
1 parent 1f190f8 commit 143ecb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions generate_configuration_parser.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gogenerate

import (
"fmt"
"os"

"github.com/mattn/go-shellwords"
Expand Down Expand Up @@ -33,15 +34,15 @@ func (p GenerateConfigurationParser) Parse() (GenerateConfiguration, error) {
generateConfiguration.Args, err = shellwordsParser.Parse(val)

if err != nil {
return GenerateConfiguration{}, err
return GenerateConfiguration{}, fmt.Errorf("BP_GO_GENERATE_ARGS=%q: %w", val, err)
}
}

if val, ok := os.LookupEnv("BP_GO_GENERATE_FLAGS"); ok {
generateConfiguration.Flags, err = shellwordsParser.Parse(val)

if err != nil {
return GenerateConfiguration{}, err
return GenerateConfiguration{}, fmt.Errorf("BP_GO_GENERATE_FLAGS=%q: %w", val, err)
}
}
return generateConfiguration, nil
Expand Down
4 changes: 2 additions & 2 deletions generate_configuration_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func testGenerateConfigurationParser(t *testing.T, context spec.G, it spec.S) {

it("returns an error", func() {
_, err := parser.Parse()
Expect(err).To(MatchError(ContainSubstring("invalid command line string")))
Expect(err).To(MatchError(ContainSubstring(`BP_GO_GENERATE_ARGS="\"": invalid command line string`)))
})

it.After(func() {
Expand All @@ -92,7 +92,7 @@ func testGenerateConfigurationParser(t *testing.T, context spec.G, it spec.S) {

it("returns an error", func() {
_, err := parser.Parse()
Expect(err).To(MatchError(ContainSubstring("invalid command line string")))
Expect(err).To(MatchError(ContainSubstring(`BP_GO_GENERATE_FLAGS="\"": invalid command line string`)))
})

it.After(func() {
Expand Down

0 comments on commit 143ecb1

Please sign in to comment.