Return error code in case of formatting failure.

This commit is contained in:
Artur Mullakhmetov 2020-03-26 18:24:21 +03:00
parent e5b3b329ea
commit 29407260ab
14 changed files with 14 additions and 0 deletions

View File

@ -63,6 +63,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatToken(t) out, err := formatter.FormatToken(t)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -137,6 +137,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatPolicy(p) out, err := formatter.FormatPolicy(p)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -69,6 +69,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatPolicyList(policies) out, err := formatter.FormatPolicyList(policies)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -91,6 +91,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatPolicy(p) out, err := formatter.FormatPolicy(p)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -168,6 +168,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatPolicy(p) out, err := formatter.FormatPolicy(p)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -123,6 +123,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatRole(r) out, err := formatter.FormatRole(r)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -69,6 +69,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatRoleList(roles) out, err := formatter.FormatRoleList(roles)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -103,6 +103,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatRole(r) out, err := formatter.FormatRole(r)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -208,6 +208,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatRole(r) out, err := formatter.FormatRole(r)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -84,6 +84,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatToken(t) out, err := formatter.FormatToken(t)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -154,6 +154,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatToken(t) out, err := formatter.FormatToken(t)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -68,6 +68,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatTokenList(tokens) out, err := formatter.FormatTokenList(tokens)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -97,6 +97,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatToken(t) out, err := formatter.FormatToken(t)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)

View File

@ -284,6 +284,7 @@ func (c *cmd) Run(args []string) int {
out, err := formatter.FormatToken(t) out, err := formatter.FormatToken(t)
if err != nil { if err != nil {
c.UI.Error(err.Error()) c.UI.Error(err.Error())
return 1
} }
if out != "" { if out != "" {
c.UI.Info(out) c.UI.Info(out)