mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-08 05:50:47 +00:00
add test and improve config error messages
This commit is contained in:
+5
-4
@@ -2,7 +2,6 @@ package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -258,9 +257,11 @@ func LoadConfig(filename string, config *ConfigStructure) error {
|
||||
if err = decJSON.Decode(&config); err != nil {
|
||||
f.Seek(0, 0)
|
||||
decYAML := yaml.NewDecoder(f)
|
||||
if err = decYAML.Decode(&config); err != nil {
|
||||
err = errors.New("not valid yaml or json")
|
||||
}
|
||||
if err2 := decYAML.Decode(&config); err2 != nil {
|
||||
err = fmt.Errorf("invalid yaml (%s) or json (%s)", err2, err)
|
||||
} else {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user