github.com/aigarnetwork/aigar@v0.0.0-20191115204914-d59a6eb70f8e/accounts/errors.go (about)

     1  //  Copyright 2018 The go-ethereum Authors
     2  //  Copyright 2019 The go-aigar Authors
     3  //  This file is part of the go-aigar library.
     4  //
     5  //  The go-aigar library is free software: you can redistribute it and/or modify
     6  //  it under the terms of the GNU Lesser General Public License as published by
     7  //  the Free Software Foundation, either version 3 of the License, or
     8  //  (at your option) any later version.
     9  //
    10  //  The go-aigar library is distributed in the hope that it will be useful,
    11  //  but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  //  GNU Lesser General Public License for more details.
    14  //
    15  //  You should have received a copy of the GNU Lesser General Public License
    16  //  along with the go-aigar library. If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package accounts
    19  
    20  import (
    21  	"errors"
    22  	"fmt"
    23  )
    24  
    25  // ErrUnknownAccount is returned for any requested operation for which no backend
    26  // provides the specified account.
    27  var ErrUnknownAccount = errors.New("unknown account")
    28  
    29  // ErrUnknownWallet is returned for any requested operation for which no backend
    30  // provides the specified wallet.
    31  var ErrUnknownWallet = errors.New("unknown wallet")
    32  
    33  // ErrNotSupported is returned when an operation is requested from an account
    34  // backend that it does not support.
    35  var ErrNotSupported = errors.New("not supported")
    36  
    37  // ErrInvalidPassphrase is returned when a decryption operation receives a bad
    38  // passphrase.
    39  var ErrInvalidPassphrase = errors.New("invalid password")
    40  
    41  // ErrWalletAlreadyOpen is returned if a wallet is attempted to be opened the
    42  // second time.
    43  var ErrWalletAlreadyOpen = errors.New("wallet already open")
    44  
    45  // ErrWalletClosed is returned if a wallet is attempted to be opened the
    46  // secodn time.
    47  var ErrWalletClosed = errors.New("wallet closed")
    48  
    49  // AuthNeededError is returned by backends for signing requests where the user
    50  // is required to provide further authentication before signing can succeed.
    51  //
    52  // This usually means either that a password needs to be supplied, or perhaps a
    53  // one time PIN code displayed by some hardware device.
    54  type AuthNeededError struct {
    55  	Needed string // Extra authentication the user needs to provide
    56  }
    57  
    58  // NewAuthNeededError creates a new authentication error with the extra details
    59  // about the needed fields set.
    60  func NewAuthNeededError(needed string) error {
    61  	return &AuthNeededError{
    62  		Needed: needed,
    63  	}
    64  }
    65  
    66  // Error implements the standard error interface.
    67  func (err *AuthNeededError) Error() string {
    68  	return fmt.Sprintf("authentication needed: %s", err.Needed)
    69  }