mirror of https://github.com/MedzikUser/imgurs
feat(lib): if body length is > 30 return `body is too length`
This commit is contained in:
parent
22bde2819e
commit
adc52ba207
|
@ -11,7 +11,12 @@ pub async fn delete_image(c: ImgurClient, delete_hash: String) -> Result<String,
|
||||||
let status = res.status();
|
let status = res.status();
|
||||||
|
|
||||||
if status.is_client_error() || status.is_server_error() {
|
if status.is_client_error() || status.is_server_error() {
|
||||||
let body = res.text().await.map_err(anyhow::Error::new)?;
|
let mut body = res.text().await.map_err(anyhow::Error::new)?;
|
||||||
|
|
||||||
|
if body.chars().count() > 30 {
|
||||||
|
body = "body is too length".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
let err = Error::new(
|
let err = Error::new(
|
||||||
ErrorKind::Other,
|
ErrorKind::Other,
|
||||||
format!("server returned non-successful status code = {status}, body = {body}"),
|
format!("server returned non-successful status code = {status}, body = {body}"),
|
||||||
|
|
|
@ -21,7 +21,12 @@ pub async fn upload_image(c: ImgurClient, image: &str) -> Result<ImageInfo, anyh
|
||||||
let status = res.status();
|
let status = res.status();
|
||||||
|
|
||||||
if status.is_client_error() || status.is_server_error() {
|
if status.is_client_error() || status.is_server_error() {
|
||||||
let body = res.text().await.map_err(anyhow::Error::new)?;
|
let mut body = res.text().await.map_err(anyhow::Error::new)?;
|
||||||
|
|
||||||
|
if body.chars().count() > 30 {
|
||||||
|
body = "body is too length".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
let err = Error::new(
|
let err = Error::new(
|
||||||
ErrorKind::Other,
|
ErrorKind::Other,
|
||||||
format!("server returned non-successful status code = {status}, body = {body}"),
|
format!("server returned non-successful status code = {status}, body = {body}"),
|
||||||
|
|
Loading…
Reference in New Issue