mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
refactor: unify the error handling methods in the crypto package that are different from the project style
Signed-off-by: ChengenH <hce19970702@gmail.com>
This commit is contained in:
parent
88cbfab332
commit
a28fcc094b
5 changed files with 8 additions and 8 deletions
|
|
@ -923,13 +923,13 @@ func testExternalUI(api *core.SignerAPI) {
|
|||
}
|
||||
}
|
||||
expectApprove := func(testcase string, err error) {
|
||||
if err == nil || err == accounts.ErrUnknownAccount {
|
||||
if err == nil || errors.Is(err, accounts.ErrUnknownAccount) {
|
||||
return
|
||||
}
|
||||
addErr(fmt.Sprintf("%v: expected no error, got %v", testcase, err.Error()))
|
||||
}
|
||||
expectDeny := func(testcase string, err error) {
|
||||
if err == nil || err != core.ErrRequestDenied {
|
||||
if err == nil || !errors.Is(err, core.ErrRequestDenied) {
|
||||
addErr(fmt.Sprintf("%v: expected ErrRequestDenied, got %v", testcase, err))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ func (c *Console) Interactive() {
|
|||
return
|
||||
|
||||
case err := <-inputErr:
|
||||
if err == liner.ErrPromptAborted {
|
||||
if errors.Is(err, liner.ErrPromptAborted) {
|
||||
// When prompting for multi-line input, the first Ctrl-C resets
|
||||
// the multi-line state.
|
||||
prompt, indents, input = c.prompt, 0, ""
|
||||
|
|
|
|||
|
|
@ -1385,7 +1385,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
|
|||
// Write downloaded chain data and corresponding receipt chain data
|
||||
if len(ancientBlocks) > 0 {
|
||||
if n, err := writeAncient(ancientBlocks, ancientReceipts); err != nil {
|
||||
if err == errInsertionInterrupted {
|
||||
if errors.Is(err, errInsertionInterrupted) {
|
||||
return 0, nil
|
||||
}
|
||||
return n, err
|
||||
|
|
@ -1393,7 +1393,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
|
|||
}
|
||||
if len(liveBlocks) > 0 {
|
||||
if n, err := writeLive(liveBlocks, liveReceipts); err != nil {
|
||||
if err == errInsertionInterrupted {
|
||||
if errors.Is(err, errInsertionInterrupted) {
|
||||
return 0, nil
|
||||
}
|
||||
return n, err
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ func (sub *ClientSubscription) run() {
|
|||
|
||||
// Send the error.
|
||||
if err != nil {
|
||||
if err == ErrClientQuit {
|
||||
if errors.Is(err, ErrClientQuit) {
|
||||
// ErrClientQuit gets here when Client.Close is called. This is reported as a
|
||||
// nil error because it's not an error, but we can't close sub.err here.
|
||||
err = nil
|
||||
|
|
@ -340,7 +340,7 @@ func (sub *ClientSubscription) forward() (unsubscribeServer bool, err error) {
|
|||
if !recv.IsNil() {
|
||||
err = recv.Interface().(error)
|
||||
}
|
||||
if err == errUnsubscribed {
|
||||
if errors.Is(err, errUnsubscribed) {
|
||||
// Exiting because Unsubscribe was called, unsubscribe on server.
|
||||
return true, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ func (it *nodeIterator) seek(prefix []byte) error {
|
|||
// Move forward until we're just before the closest match to key.
|
||||
for {
|
||||
state, parentIndex, path, err := it.peekSeek(key)
|
||||
if err == errIteratorEnd {
|
||||
if errors.Is(err, errIteratorEnd) {
|
||||
return errIteratorEnd
|
||||
} else if err != nil {
|
||||
return seekError{prefix, err}
|
||||
|
|
|
|||
Loading…
Reference in a new issue