Skip to content

Commit

Permalink
Fix nil error issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bitcodr committed Aug 1, 2020
1 parent 4f416bf commit 1d3c051
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/fscrypt/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ func addProtectorAction(c *cli.Context) error {
return newExitError(c, err)
}
// Sanity check before unlocking everything
if err := policy.AddProtector(protector); errors.Cause(err) != actions.ErrLocked {
if err := policy.AddProtector(protector); err != nil && errors.Cause(err) != actions.ErrLocked {
return newExitError(c, err)
}

Expand Down
4 changes: 0 additions & 4 deletions cmd/fscrypt/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,6 @@ func getErrorSuggestions(err error) string {
// returned error prepends an error tag and the name of the relevant command,
// and it will make fscrypt return a non-zero exit value.
func newExitError(c *cli.Context, err error) error {
if err == nil {
return nil
}

// Prepend the error tag and full name, and append suggestions (if any)
prefix := "[ERROR] " + getFullName(c) + ": "
message := prefix + wrapText(err.Error(), utf8.RuneCountInString(prefix))
Expand Down

0 comments on commit 1d3c051

Please sign in to comment.