rpcerrors

package
v0.0.0-...-29e199f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParseErrorCode              ErrorCode = -32700
	InvalidRequestErrorCode     ErrorCode = -32600
	MethodNotFoundErrorCode     ErrorCode = -32601
	InvalidParamsErrorCode      ErrorCode = -32602
	InternalErrorCode           ErrorCode = -32603
	UnauthorizedErrorCode       ErrorCode = -32099
	NotFoundErrorCode           ErrorCode = -32098
	PreconditionFailedErrorCode ErrorCode = -32097

	ParseErrorMsg              ErrorMsg = "Parse error"
	InvalidRequestErrorMsg     ErrorMsg = "Invalid request"
	MethodNotFoundErrorMsg     ErrorMsg = "Method not found"
	InvalidParamsErrorMsg      ErrorMsg = "Invalid params"
	InternalErrorMsg           ErrorMsg = "Internal error"
	UnauthorizedErrorMsg       ErrorMsg = "Unauthorized"
	NotFoundErrorMsg           ErrorMsg = "Not found"
	PreconditionFailedErrorMsg ErrorMsg = "Precondition failed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode int

ErrorCode defines a json rpc 2.0 error code.

type ErrorMsg

type ErrorMsg string

ErrorMsg defines a json rpc 2.0 error message.

type RPCError

type RPCError struct {
	// Code indicates the error type that occurred.
	Code ErrorCode `json:"code"`
	// Message provides a short description of the error.
	Message ErrorMsg `json:"message"`
	// WrappedErr contains the original error (if any).
	WrappedErr error `json:"-"`
}

RPCError as defined in: https://www.jsonrpc.org/specification

func CastAsRPCError

func CastAsRPCError(err error) (*RPCError, bool)

CastAsRPCError casts the provided error as an RPC error type

func NewInternal

func NewInternal() *RPCError

NewInternal creates a new internal server RPCError.

func NewInternalFromErr

func NewInternalFromErr(err error) *RPCError

NewInternalFromErr creates a new internal server RPCError wrapping the original error.

func NewInvalidParams

func NewInvalidParams() *RPCError

NewInvalidParams creates a new invalid params RPCError.

func NewInvalidParamsFromErr

func NewInvalidParamsFromErr(err error) *RPCError

NewInvalidParamsFromErr creates a new invalid params RPCError wrapping the original error.

func NewInvalidRequest

func NewInvalidRequest() *RPCError

NewInvalidRequest creates a new invalid request RPCError.

func NewInvalidRequestFromErr

func NewInvalidRequestFromErr(err error) *RPCError

NewInvalidRequestFromErr creates a new invalid request RPCError wrapping the original error.

func NewMethodNotFound

func NewMethodNotFound() *RPCError

NewMethodNotFound creates a new method not found RPCError.

func NewMethodNotFoundFromErr

func NewMethodNotFoundFromErr(err error) *RPCError

NewMethodNotFoundFromErr creates a new method not found RPCError wrapping the original error.

func NewNotFound

func NewNotFound() *RPCError

NewNotFound creates a new method not found RPCError.

func NewNotFoundFromErr

func NewNotFoundFromErr(err error) *RPCError

NewNotFoundFromErr creates a new not found RPCError wrapping the original error.

func NewParse

func NewParse() *RPCError

NewParse creates a new parse RPCError.

func NewParseFromErr

func NewParseFromErr(err error) *RPCError

NewParseFromErr creates a new parse RPCError wrapping the original error.

func NewPreconditionFailed

func NewPreconditionFailed() *RPCError

NewPreconditionFailed creates a new method not found RPCError.

func NewPreconditionFailedFromErr

func NewPreconditionFailedFromErr(err error) *RPCError

NewPreconditionFailedFromErr creates a new not found RPCError wrapping the original error.

func NewUnauthorized

func NewUnauthorized() *RPCError

NewUnauthorized creates a new no authorized RPCError.

func NewUnauthorizedFromErr

func NewUnauthorizedFromErr(err error) *RPCError

NewUnauthorizedFromErr creates a new no authorized RPCError wrapping the original error.

func (*RPCError) Error

func (rpcError *RPCError) Error() string

Error implements error interface

func (*RPCError) Marshal

func (rpcError *RPCError) Marshal() *json.RawMessage

Marshal implements json.Marshaller.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL