kopia lustrzana https://github.com/bugout-dev/moonstream
Err handling for Bugout client creation
rodzic
96886a56a0
commit
9a0b7eb8f0
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
Ładowanie…
Reference in New Issue