feat(lib): if body length is > 30 return `body is too length`

This commit is contained in:
MedzikUser 2022-03-02 22:10:56 +01:00
parent 22bde2819e
commit adc52ba207
No known key found for this signature in database
GPG Key ID: A5FAC1E185C112DB
2 changed files with 12 additions and 2 deletions

View File

@ -11,7 +11,12 @@ pub async fn delete_image(c: ImgurClient, delete_hash: String) -> Result<String,
let status = res.status();
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(
ErrorKind::Other,
format!("server returned non-successful status code = {status}, body = {body}"),

View File

@ -21,7 +21,12 @@ pub async fn upload_image(c: ImgurClient, image: &str) -> Result<ImageInfo, anyh
let status = res.status();
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(
ErrorKind::Other,
format!("server returned non-successful status code = {status}, body = {body}"),