config_file.go: return error if config is invalid
This commit is contained in:
parent
4890bc4cc7
commit
bb24f62b9c
@ -14,8 +14,11 @@ func configFileLoad(filepath string) error {
|
||||
|
||||
defer file.Close()
|
||||
|
||||
num := 0
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
num += 1
|
||||
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
if line == "" {
|
||||
continue
|
||||
@ -27,7 +30,8 @@ func configFileLoad(filepath string) error {
|
||||
|
||||
i := strings.Index(line, "=")
|
||||
if i == -1 {
|
||||
continue
|
||||
logger.Errorf("%s: line %d: neither a comment nor a valid setting", filepath, num)
|
||||
return errorInvalidConfigFile
|
||||
}
|
||||
|
||||
key := line[:i]
|
||||
|
@ -38,3 +38,4 @@ var errorNotADirectory = errors.New("The given path is not a directory.")
|
||||
var errorGzip = errors.New("Cannot GZip content.")
|
||||
var errorCannotDownloadDisqus = errors.New("We could not download your Disqus export file.")
|
||||
var errorSelfVote = errors.New("You cannot vote on your own comment.")
|
||||
var errorInvalidConfigFile = errors.New("Invalid config file.")
|
||||
|
Loading…
Reference in New Issue
Block a user