Skip to content

Commit 148f6f0

Browse files
committed
error: move Error struct to error.go
1 parent c675c6a commit 148f6f0

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

error.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,24 @@ const (
2121
RequestCancelled ErrorCode = -32800
2222
ContentModified ErrorCode = -32801
2323
)
24+
25+
// Error ...
26+
type Error struct {
27+
28+
// Code a number indicating the error type that occurred.
29+
Code ErrorCode `json:"code"`
30+
31+
// Data a Primitive or Structured value that contains additional
32+
// information about the error. Can be omitted.
33+
Data []byte `json:"data"`
34+
35+
// Message a string providing a short description of the error.
36+
Message string `json:"message"`
37+
}
38+
39+
func (err *Error) Error() string {
40+
if err == nil {
41+
return ""
42+
}
43+
return err.Message
44+
}

types.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,6 @@ type Response struct {
5555
Result []byte `json:"result,omitempty"`
5656
}
5757

58-
// Error ...
59-
type Error struct {
60-
61-
// Code a number indicating the error type that occurred.
62-
Code ErrorCode `json:"code"`
63-
64-
// Data a Primitive or Structured value that contains additional
65-
// information about the error. Can be omitted.
66-
Data []byte `json:"data"`
67-
68-
// Message a string providing a short description of the error.
69-
Message string `json:"message"`
70-
}
71-
72-
func (err *Error) Error() string {
73-
if err == nil {
74-
return ""
75-
}
76-
return err.Message
77-
}
78-
7958
type NotificationMessage struct {
8059
Message
8160

0 commit comments

Comments
 (0)