@@ -114,22 +114,24 @@ module Response = struct
114
114
| ServerCancelled
115
115
| ContentModified
116
116
| RequestCancelled
117
+ (* all other codes are custom *)
118
+ | Other of int
117
119
118
120
let of_int = function
119
- | - 32700 -> Some ParseError
120
- | - 32600 -> Some InvalidRequest
121
- | - 32601 -> Some MethodNotFound
122
- | - 32602 -> Some InvalidParams
123
- | - 32603 -> Some InternalError
124
- | - 32099 -> Some ServerErrorStart
125
- | - 32000 -> Some ServerErrorEnd
126
- | - 32002 -> Some ServerNotInitialized
127
- | - 32001 -> Some UnknownErrorCode
128
- | - 32800 -> Some RequestCancelled
129
- | - 32801 -> Some ContentModified
130
- | - 32802 -> Some ServerCancelled
131
- | - 32803 -> Some RequestFailed
132
- | _ -> None
121
+ | - 32700 -> ParseError
122
+ | - 32600 -> InvalidRequest
123
+ | - 32601 -> MethodNotFound
124
+ | - 32602 -> InvalidParams
125
+ | - 32603 -> InternalError
126
+ | - 32099 -> ServerErrorStart
127
+ | - 32000 -> ServerErrorEnd
128
+ | - 32002 -> ServerNotInitialized
129
+ | - 32001 -> UnknownErrorCode
130
+ | - 32800 -> RequestCancelled
131
+ | - 32801 -> ContentModified
132
+ | - 32802 -> ServerCancelled
133
+ | - 32803 -> RequestFailed
134
+ | code -> Other code
133
135
134
136
let to_int = function
135
137
| ParseError -> - 32700
@@ -145,13 +147,11 @@ module Response = struct
145
147
| ContentModified -> - 32801
146
148
| ServerCancelled -> - 32802
147
149
| RequestFailed -> - 32803
150
+ | Other code -> code
148
151
149
152
let t_of_yojson json =
150
153
match json with
151
- | `Int i -> (
152
- match of_int i with
153
- | None -> Json. error " unknown code" json
154
- | Some i -> i)
154
+ | `Int i -> of_int i
155
155
| _ -> Json. error " invalid code" json
156
156
157
157
let yojson_of_t t = `Int (to_int t)
0 commit comments