github.com/arieschain/arieschain@v0.0.0-20191023063405-37c074544356/rpc/errors.go (about)

     1  package rpc
     2  
     3  import "fmt"
     4  
     5  // request is for an unknown service
     6  type methodNotFoundError struct {
     7  	service string
     8  	method  string
     9  }
    10  
    11  func (e *methodNotFoundError) ErrorCode() int { return -32601 }
    12  
    13  func (e *methodNotFoundError) Error() string {
    14  	return fmt.Sprintf("The method %s%s%s does not exist/is not available", e.service, serviceMethodSeparator, e.method)
    15  }
    16  
    17  // received message isn't a valid request
    18  type invalidRequestError struct{ message string }
    19  
    20  func (e *invalidRequestError) ErrorCode() int { return -32600 }
    21  
    22  func (e *invalidRequestError) Error() string { return e.message }
    23  
    24  // received message is invalid
    25  type invalidMessageError struct{ message string }
    26  
    27  func (e *invalidMessageError) ErrorCode() int { return -32700 }
    28  
    29  func (e *invalidMessageError) Error() string { return e.message }
    30  
    31  // unable to decode supplied params, or an invalid number of parameters
    32  type invalidParamsError struct{ message string }
    33  
    34  func (e *invalidParamsError) ErrorCode() int { return -32602 }
    35  
    36  func (e *invalidParamsError) Error() string { return e.message }
    37  
    38  // logic error, callback returned an error
    39  type callbackError struct{ message string }
    40  
    41  func (e *callbackError) ErrorCode() int { return -32000 }
    42  
    43  func (e *callbackError) Error() string { return e.message }
    44  
    45  // issued when a request is received after the server is issued to stop.
    46  type shutdownError struct{}
    47  
    48  func (e *shutdownError) ErrorCode() int { return -32000 }
    49  
    50  func (e *shutdownError) Error() string { return "server is shutting down" }