Skip to content

Commit

Permalink
Improved error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dgil committed Jun 22, 2016
1 parent 4f067b7 commit 25662a6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
)

const (
slackTokenLabel string = "KUBEBOT_SLACK_TOKEN"
slackChannelsLabel string = "KUBEBOT_SLACK_CHANNELS_IDS"
slackAdminsLabel string = "KUBEBOT_SLACK_ADMINS_NICKNAMES"
slackCommandsLabel string = "KUBEBOT_SLACK_VALID_COMMANDS"
slackTokenLabel string = "KUBEBOT_SLACK_TOKEN"
slackChannelsLabel string = "KUBEBOT_SLACK_CHANNELS_IDS"
slackAdminsLabel string = "KUBEBOT_SLACK_ADMINS_NICKNAMES"
slackCommandsLabel string = "KUBEBOT_SLACK_VALID_COMMANDS"
notDefinedErrorMessage string = "%s env variable not defined"
)

var (
Expand All @@ -21,16 +22,16 @@ var (

func validateEnvParams() error {
if os.Getenv(slackTokenLabel) == "" {
return errors.New("slackTokenLabel env variable not defined")
return errors.New(fmt.Sprintf(notDefinedErrorMessage, slackTokenLabel))
}
if os.Getenv(slackChannelsLabel) == "" {
return errors.New("slackChannelsLabel env variable not defined")
return errors.New(fmt.Sprintf(notDefinedErrorMessage, slackChannelsLabel))
}
if os.Getenv(slackAdminsLabel) == "" {
return errors.New("slackAdminsLabel env variable not defined")
return errors.New(fmt.Sprintf(notDefinedErrorMessage, slackAdminsLabel))
}
if os.Getenv(slackCommandsLabel) == "" {
return errors.New("slackCommandsLabel env variable not defined")
return errors.New(fmt.Sprintf(notDefinedErrorMessage, slackCommandsLabel))
}

return nil
Expand Down

0 comments on commit 25662a6

Please sign in to comment.