diff options
Diffstat (limited to 'crates/server/src/dispatch.rs')
-rw-r--r-- | crates/server/src/dispatch.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/crates/server/src/dispatch.rs b/crates/server/src/dispatch.rs index 3a3ee74bb..d8cca48d0 100644 --- a/crates/server/src/dispatch.rs +++ b/crates/server/src/dispatch.rs | |||
@@ -30,8 +30,12 @@ impl<R: ClientRequest> Responder<R> { | |||
30 | error: serde_json::Value::Null, | 30 | error: serde_json::Value::Null, |
31 | } | 31 | } |
32 | } | 32 | } |
33 | Err(_) => { | 33 | Err(e) => { |
34 | error_response(self.id, ErrorCode::InternalError, "internal error")? | 34 | error_response( |
35 | self.id, | ||
36 | ErrorCode::InternalError, | ||
37 | format!("internal error: {}", e), | ||
38 | )? | ||
35 | } | 39 | } |
36 | }; | 40 | }; |
37 | Ok(res) | 41 | Ok(res) |
@@ -115,21 +119,20 @@ pub fn send_notification<N>(params: N::Params) -> RawNotification | |||
115 | 119 | ||
116 | pub fn unknown_method(id: u64) -> Result<RawResponse> { | 120 | pub fn unknown_method(id: u64) -> Result<RawResponse> { |
117 | error_response(id, ErrorCode::MethodNotFound, "unknown method") | 121 | error_response(id, ErrorCode::MethodNotFound, "unknown method") |
118 | |||
119 | } | 122 | } |
120 | 123 | ||
121 | fn error_response(id: u64, code: ErrorCode, message: &'static str) -> Result<RawResponse> { | 124 | fn error_response(id: u64, code: ErrorCode, message: impl Into<String>) -> Result<RawResponse> { |
122 | #[derive(Serialize)] | 125 | #[derive(Serialize)] |
123 | struct Error { | 126 | struct Error { |
124 | code: i32, | 127 | code: i32, |
125 | message: &'static str, | 128 | message: String, |
126 | } | 129 | } |
127 | let resp = RawResponse { | 130 | let resp = RawResponse { |
128 | id, | 131 | id, |
129 | result: serde_json::Value::Null, | 132 | result: serde_json::Value::Null, |
130 | error: serde_json::to_value(Error { | 133 | error: serde_json::to_value(Error { |
131 | code: code as i32, | 134 | code: code as i32, |
132 | message, | 135 | message: message.into(), |
133 | })?, | 136 | })?, |
134 | }; | 137 | }; |
135 | Ok(resp) | 138 | Ok(resp) |