Preventing panics of RecoverableError casts
This commit is contained in:
parent
d470fe494d
commit
429fdb3ce7
|
@ -944,7 +944,7 @@ func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest,
|
|||
// setErr is a helper for setting the recoverable error on the reply and
|
||||
// logging it
|
||||
setErr := func(e error, recoverable bool) {
|
||||
reply.Error = structs.NewRecoverableError(e, recoverable).(*structs.RecoverableError)
|
||||
reply.Error = structs.NewRecoverableError(e, recoverable)
|
||||
n.srv.logger.Printf("[ERR] nomad.client: DeriveVaultToken failed (recoverable %v): %v", recoverable, e)
|
||||
}
|
||||
|
||||
|
@ -1134,7 +1134,7 @@ func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest,
|
|||
if rerr, ok := createErr.(*structs.RecoverableError); ok {
|
||||
reply.Error = rerr
|
||||
} else {
|
||||
reply.Error = structs.NewRecoverableError(createErr, false).(*structs.RecoverableError)
|
||||
reply.Error = structs.NewRecoverableError(createErr, false)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -4054,7 +4054,7 @@ type RecoverableError struct {
|
|||
|
||||
// NewRecoverableError is used to wrap an error and mark it as recoverable or
|
||||
// not.
|
||||
func NewRecoverableError(e error, recoverable bool) error {
|
||||
func NewRecoverableError(e error, recoverable bool) *RecoverableError {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue