diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-07-24 16:11:47 +0200 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2018-07-24 10:11:47 -0400 |
commit | bfb2640451c95b242ae7b8bb8528538b706412ef (patch) | |
tree | 0287dc30c4fa70a3c457371dfd5cfd1a7d91376f /cmd/mattermost/commands/message_export.go | |
parent | da124f018dbb10a41f4d4b5ecb4818baf628e940 (diff) | |
download | chat-bfb2640451c95b242ae7b8bb8528538b706412ef.tar.gz chat-bfb2640451c95b242ae7b8bb8528538b706412ef.tar.bz2 chat-bfb2640451c95b242ae7b8bb8528538b706412ef.zip |
Add idiomatic error handling in mattermost commands (#9147)
Diffstat (limited to 'cmd/mattermost/commands/message_export.go')
-rw-r--r-- | cmd/mattermost/commands/message_export.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/cmd/mattermost/commands/message_export.go b/cmd/mattermost/commands/message_export.go index ae97eacfb..e7d82a8c1 100644 --- a/cmd/mattermost/commands/message_export.go +++ b/cmd/mattermost/commands/message_export.go @@ -78,23 +78,27 @@ func scheduleExportCmdF(command *cobra.Command, args []string) error { } // for now, format is hard-coded to actiance. In time, we'll have to support other formats and inject them into job data - if format, err := command.Flags().GetString("format"); err != nil { + format, err := command.Flags().GetString("format") + if err != nil { return errors.New("format flag error") - } else if format != "actiance" { + } + if format != "actiance" { return errors.New("unsupported export format") } startTime, err := command.Flags().GetInt64("exportFrom") if err != nil { return errors.New("exportFrom flag error") - } else if startTime < 0 { + } + if startTime < 0 { return errors.New("exportFrom must be a positive integer") } timeoutSeconds, err := command.Flags().GetInt("timeoutSeconds") if err != nil { return errors.New("timeoutSeconds error") - } else if timeoutSeconds < 0 { + } + if timeoutSeconds < 0 { return errors.New("timeoutSeconds must be a positive integer") } @@ -128,7 +132,8 @@ func buildExportCmdF(format string) func(command *cobra.Command, args []string) startTime, err := command.Flags().GetInt64("exportFrom") if err != nil { return errors.New("exportFrom flag error") - } else if startTime < 0 { + } + if startTime < 0 { return errors.New("exportFrom must be a positive integer") } |