notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 920ee183b43b22d2b7158dd7ec2f67ad56682e96
parent 0d92c26ae46f187e71984fc5bed46fe1af42c7ee
Author: Sergey B <sergey3bv@gmail.com>
Date:   Tue,  3 Feb 2026 19:01:51 +0300

media_upload: use io::Error for HTTP error responses

Replace generic error with io::Error for unsuccessful HTTP responses
in NIP-96 media uploads, mapping status codes to appropriate ErrorKind
variants.

Closes: https://github.com/damus-io/notedeck/pull/1281

Diffstat:
Mcrates/notedeck_columns/src/media_upload.rs | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/crates/notedeck_columns/src/media_upload.rs b/crates/notedeck_columns/src/media_upload.rs @@ -1,5 +1,7 @@ #![cfg_attr(target_os = "android", allow(dead_code, unused_variables))] +use std::io; + use crate::Error; use base64::{prelude::BASE64_URL_SAFE, Engine}; use ehttp::Request; @@ -205,10 +207,17 @@ fn internal_nip96_upload( Err(e) => Err(Error::Generic(e.to_string())), } } else { - Err(Error::Generic(format!( + let kind = match response.status { + 400..=499 => io::ErrorKind::InvalidInput, + 500..=599 => io::ErrorKind::ConnectionAborted, + _ => io::ErrorKind::Other, + }; + let err_msg = format!( "ehttp Response was unsuccessful. Code {} with message: {}", response.status, response.status_text - ))) + ); + + Err(Error::Io(io::Error::new(kind, err_msg))) } } Err(e) => Err(Error::Generic(e)),