github.com/linapex/ethereum-go-chinese@v0.0.0-20190316121929-f8b7a73c3fa1/rpc/errors.go (about)

     1  
     2  //<developer>
     3  //    <name>linapex 曹一峰</name>
     4  //    <email>linapex@163.com</email>
     5  //    <wx>superexc</wx>
     6  //    <qqgroup>128148617</qqgroup>
     7  //    <url>https://jsq.ink</url>
     8  //    <role>pku engineer</role>
     9  //    <date>2019-03-16 19:16:42</date>
    10  //</624450108720680960>
    11  
    12  
    13  package rpc
    14  
    15  import "fmt"
    16  
    17  //请求用于未知服务
    18  type methodNotFoundError struct {
    19  	service string
    20  	method  string
    21  }
    22  
    23  func (e *methodNotFoundError) ErrorCode() int { return -32601 }
    24  
    25  func (e *methodNotFoundError) Error() string {
    26  	return fmt.Sprintf("The method %s%s%s does not exist/is not available", e.service, serviceMethodSeparator, e.method)
    27  }
    28  
    29  //收到的消息不是有效的请求
    30  type invalidRequestError struct{ message string }
    31  
    32  func (e *invalidRequestError) ErrorCode() int { return -32600 }
    33  
    34  func (e *invalidRequestError) Error() string { return e.message }
    35  
    36  //接收到的消息无效
    37  type invalidMessageError struct{ message string }
    38  
    39  func (e *invalidMessageError) ErrorCode() int { return -32700 }
    40  
    41  func (e *invalidMessageError) Error() string { return e.message }
    42  
    43  //无法解码提供的参数,或参数数目无效
    44  type invalidParamsError struct{ message string }
    45  
    46  func (e *invalidParamsError) ErrorCode() int { return -32602 }
    47  
    48  func (e *invalidParamsError) Error() string { return e.message }
    49  
    50  //逻辑错误,回调返回错误
    51  type callbackError struct{ message string }
    52  
    53  func (e *callbackError) ErrorCode() int { return -32000 }
    54  
    55  func (e *callbackError) Error() string { return e.message }
    56  
    57  //在服务器发出停止后收到请求时发出。
    58  type shutdownError struct{}
    59  
    60  func (e *shutdownError) ErrorCode() int { return -32000 }
    61  
    62  func (e *shutdownError) Error() string { return "server is shutting down" }
    63