diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 95caf6b..d06e862 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1764,7 +1764,7 @@ dependencies = [ [[package]] name = "wechatbot" -version = "0.3.0" +version = "0.3.1" dependencies = [ "aes", "base64", diff --git a/rust/src/protocol.rs b/rust/src/protocol.rs index ad4db6c..f5c6059 100644 --- a/rust/src/protocol.rs +++ b/rust/src/protocol.rs @@ -230,6 +230,20 @@ impl ILinkClient { }); } + if let Some(errcode) = value["errcode"].as_i64() { + if errcode != 0 { + return Err(WeChatBotError::Api { + message: value["errmsg"] + .as_str() + .or_else(|| value["message"].as_str()) + .unwrap_or(&text) + .to_string(), + http_status: status, + errcode: errcode as i32, + }); + } + } + Ok(value) } }