1
0
mirror of https://github.com/shirou/mqttcli.git synced 2025-04-28 13:48:50 +08:00

add error handling.

This commit is contained in:
Shirou WAKAYAMA 2016-07-25 22:34:06 +09:00
parent 874c9cc77c
commit 37dd8ed965
3 changed files with 13 additions and 3 deletions

View File

@ -257,7 +257,10 @@ func main() {
Action: pubsub,
},
}
app.Run(os.Args)
err := app.Run(os.Args)
if err != nil {
log.Error(err)
}
}
func setDebugLevel(c *cli.Context) {

View File

@ -107,7 +107,10 @@ func NewOption(c *cli.Context) (*MQTT.ClientOptions, error) {
port := c.Int("p")
if host == "" {
getSettingsFromFile(c.String("conf"), opts)
err := getSettingsFromFile(c.String("conf"), opts)
if err != nil {
return nil, err
}
}
clientId := c.String("i")

View File

@ -51,5 +51,9 @@ func publish(c *cli.Context) {
}
log.Info("Published")
client.Disconnect()
err = client.Disconnect()
if err != nil {
log.Errorf("disconnect error: %s", err)
}
}