Tell the user if given an invalid / non-existant config file (fix #29)
This commit is contained in:
		| @ -25,7 +25,7 @@ func parseConfig(path string, config *Configuration) { | |||||||
| 	var data map[string]interface{} | 	var data map[string]interface{} | ||||||
| 	err := json.NewDecoder(file).Decode(&data) | 	err := json.NewDecoder(file).Decode(&data) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		log.Panic("Failed to parse config:", err) | 		log.Panic("Failed to parse config: ", err) | ||||||
| 	} | 	} | ||||||
| 	file.Close() | 	file.Close() | ||||||
| 	// Main configuration | 	// Main configuration | ||||||
|  | |||||||
							
								
								
									
										7
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								main.go
									
									
									
									
									
								
							| @ -82,6 +82,13 @@ func main() { | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if exists, err := fileExists(*config_path); !exists { | ||||||
|  | 		fmt.Printf("Invalid config file '%s'\n", *config_path) | ||||||
|  | 		os.Exit(1) | ||||||
|  | 	} else if err != nil { | ||||||
|  | 		panic(err) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	parseConfig(*config_path, &configuration) // Parse JSON configuration file | 	parseConfig(*config_path, &configuration) // Parse JSON configuration file | ||||||
|  |  | ||||||
| 	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { // Webhook receiver | 	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { // Webhook receiver | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user