Skip to content

Commit 0351d87

Browse files
committed
Fix error handling
1 parent d22421a commit 0351d87

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/client/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ impl Client {
226226
.map_err(|err| Error::ConnectionError { error: err })
227227
.await?;
228228

229-
if res.status() == StatusCode::UNAUTHORIZED || res.status() == StatusCode::FORBIDDEN {
230-
return Err(Error::AuthorizationError);
229+
match res.status() {
230+
StatusCode::UNAUTHORIZED => return Err(Error::AuthorizationError),
231+
StatusCode::FORBIDDEN => return Err(Error::AuthenticationError),
232+
_ => {},
231233
}
232234

233235
let s = res.text().await.map_err(|_| Error::DeserializationError {

src/integrations/serde_integration.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ impl Client {
128128
.await
129129
.map_err(|err| Error::ConnectionError { error: err })?;
130130

131-
if res.status() == StatusCode::UNAUTHORIZED || res.status() == StatusCode::FORBIDDEN {
132-
return Err(Error::AuthorizationError);
131+
match res.status() {
132+
StatusCode::UNAUTHORIZED => return Err(Error::AuthorizationError),
133+
StatusCode::FORBIDDEN => return Err(Error::AuthenticationError),
134+
_ => {}
133135
}
134136

135137
let body = res.bytes().await.map_err(|err| Error::ProtocolError {

0 commit comments

Comments
 (0)