Err handling for Bugout client creation

pull/792/head
kompotkot 2023-05-31 14:20:53 +00:00
rodzic 96886a56a0
commit 9a0b7eb8f0
2 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -224,7 +224,11 @@ func cli() {
}
// Init bugout client
bc := CreateBugoutClient()
bc, err := CreateBugoutClient()
if err != nil {
log.Printf("An error occurred during Bugout client creation: %v", err)
os.Exit(1)
}
bugoutClient = bc
// Parse subcommands and appropriate FlagSet

Wyświetl plik

@ -60,16 +60,15 @@ var (
DEFAULT_AUTOGENERATED_MAX_CALLS_PER_PERIOD = int64(1000)
)
func CreateBugoutClient() bugout.BugoutClient {
func CreateBugoutClient() (bugout.BugoutClient, error) {
bugoutTimeoutSeconds, err := strconv.Atoi(NB_BUGOUT_TIMEOUT_SECONDS_RAW)
if err != nil {
log.Printf("Unable to parse environment variable as integer: %v", err)
os.Exit(1)
return bugout.BugoutClient{}, fmt.Errorf("unable to parse environment variable as integer: %v", err)
}
NB_BUGOUT_TIMEOUT_SECONDS := time.Duration(bugoutTimeoutSeconds) * time.Second
broodClient := bugout.ClientBrood(BUGOUT_BROOD_URL, NB_BUGOUT_TIMEOUT_SECONDS)
return broodClient
return broodClient, nil
}
func CheckEnvVarSet() {