Skip to content

Commit

Permalink
add error type
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Fontanier committed Jun 3, 2024
1 parent 470c8fd commit b0a0983
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion eventsource-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl ResponseWrapper {
let key = key.as_str();
let value = match value.to_str() {
Ok(value) => value,
Err(err) => return Err(Error::InvalidParameter(Box::new(err))),
Err(err) => return Err(Error::InvalidResponseHeader(Box::new(err))),
};
map.insert(key, value);
}
Expand Down Expand Up @@ -70,6 +70,8 @@ pub enum Error {
MalformedLocationHeader(Box<dyn std::error::Error + Send + Sync + 'static>),
/// Reached maximum redirect limit after encountering Location headers.
MaxRedirectLimitReached(u32),
// Invalid response header.
InvalidResponseHeader(Box<dyn std::error::Error + Send + Sync + 'static>),
}

impl std::fmt::Display for Error {
Expand All @@ -90,6 +92,7 @@ impl std::fmt::Display for Error {
InvalidEvent => write!(f, "invalid event"),
MalformedLocationHeader(err) => write!(f, "malformed header: {err}"),
MaxRedirectLimitReached(limit) => write!(f, "maximum redirect limit reached: {limit}"),
InvalidResponseHeader(err) => write!(f, "invalid response header: {err}"),
}
}
}
Expand Down

0 comments on commit b0a0983

Please sign in to comment.