-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement error interface for Error and move ErrorCode to its own file
- Loading branch information
Showing
4 changed files
with
47 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package jsonrpc2 | ||
|
||
// ErrorCode represent the int JSON RPC 2.0 error code. | ||
type ErrorCode int | ||
|
||
// Official JSON-RPC 2.0 Spec Error Codes and Messages | ||
const ( | ||
LowestReservedErrorCode ErrorCode = -32768 | ||
ParseErrorCode ErrorCode = -32700 | ||
InvalidRequestCode ErrorCode = -32600 | ||
MethodNotFoundCode ErrorCode = -32601 | ||
InvalidParamsCode ErrorCode = -32602 | ||
InternalErrorCode ErrorCode = -32603 | ||
HighestReservedErrorCode ErrorCode = -32000 | ||
|
||
ParseErrorMessage = "Parse error" | ||
InvalidRequestMessage = "Invalid Request" | ||
MethodNotFoundMessage = "Method not found" | ||
InvalidParamsMessage = "Invalid params" | ||
InternalErrorMessage = "Internal error" | ||
) | ||
|
||
// IsReserved returns true if c is within the reserved error code range: | ||
// [LowestReservedErrorCode, HighestReservedErrorCode]. | ||
func (c ErrorCode) IsReserved() bool { | ||
return LowestReservedErrorCode <= c && c <= HighestReservedErrorCode | ||
} |
File renamed without changes.