diff options
| author | Illia Volochii <[email protected]> | 2018-05-14 22:18:05 +0300 |
|---|---|---|
| committer | Illia Volochii <[email protected]> | 2018-05-14 22:18:05 +0300 |
| commit | 89714b6f48fc2660e3fa633ebb7b86c07ce0da01 (patch) | |
| tree | 6789cd15a70b0976fa7ce821903d2747239e82ef /parse.go | |
| parent | fa5fe315f85333e5e7dc0b2147cbe3aae3e4afce (diff) | |
Fix the problem with errors
Diffstat (limited to 'parse.go')
| -rw-r--r-- | parse.go | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -276,19 +276,28 @@ func process(specs []*spec, args []string) error { } if spec.env != "" { if value, found := os.LookupEnv(spec.env); found { - var err error if spec.multiple { // expect a CSV string in an environment // variable in the case of multiple values values, err := csv.NewReader(strings.NewReader(value)).Read() - if err == nil { - err = setSlice(spec.dest, values, !spec.separate) + if err != nil { + return fmt.Errorf( + "error reading a CSV string from environment variable %s with multiple values: %v", + spec.env, + err, + ) + } + if err = setSlice(spec.dest, values, !spec.separate); err != nil { + return fmt.Errorf( + "error processing environment variable %s with multiple values: %v", + spec.env, + err, + ) } } else { - err = scalar.ParseValue(spec.dest, value) - } - if err != nil { - return fmt.Errorf("error processing environment variable %s: %v", spec.env, err) + if err := scalar.ParseValue(spec.dest, value); err != nil { + return fmt.Errorf("error processing environment variable %s: %v", spec.env, err) + } } spec.wasPresent = true } |
