Skip to content

Commit

Permalink
fix: log the 503 message (#90)
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
berendsliedrecht authored Mar 9, 2022
1 parent c8c8523 commit 3f398c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions agent-controller/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub enum Error {
InternalServerError,
UnknownResponseStatusCode,
UnreachableUrl,
HttpServiceUnavailable,
}

impl std::error::Error for Error {}
Expand All @@ -23,6 +24,8 @@ impl Display for Error {
Error::InternalServerError => write!(f, "Internal Server Error!"),
Error::UnknownResponseStatusCode => write!(f, "Received unknown status code from the server. Endpoint is likely incorrect. If the endpoint is correct, please report this error."),
Error::UnreachableUrl => write!(f, "Provided url is unreachable. Is the provided endpoint valid?"),
Error::HttpServiceUnavailable => write!(f, "Cloudagent is currently unavailable. Are you sure the agent is online?")

}
}
}
20 changes: 11 additions & 9 deletions agent-controller/src/web.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::error::{self, Result};
use crate::error::{Error, Result};
use reqwest::{Client, RequestBuilder, Url};
use serde::de::DeserializeOwned;
use serde_json::Value;
Expand Down Expand Up @@ -47,19 +47,21 @@ impl CloudAgent {

match client.send().await {
Ok(res) => match res.status().as_u16() {
200..=299 => res.json().await.map_err(|_|
error::Error::UnableToParseResponse.into()
),
200..=299 => res
.json()
.await
.map_err(|_| Error::UnableToParseResponse.into()),
// Issue credential message when attributes are not correct
400 => Err(res.text().await?.into()),
401 => Err(error::Error::AuthorizationFailed.into()),
404 => Err(error::Error::UrlDoesNotExist.into()),
401 => Err(Error::AuthorizationFailed.into()),
404 => Err(Error::UrlDoesNotExist.into()),
// TODO: This response is quite ugly. Is it only used at cred_def_id?
422 => Err(res.text().await?.into()),
500..=599 => Err(error::Error::InternalServerError.into()),
_ => Err(error::Error::UnknownResponseStatusCode.into()),
503 => Err(Error::HttpServiceUnavailable.into()),
500..=599 => Err(Error::InternalServerError.into()),
_ => Err(Error::UnknownResponseStatusCode.into()),
},
Err(_) => Err(error::Error::UnreachableUrl.into()),
Err(_) => Err(Error::UnreachableUrl.into()),
}
}
}
1 change: 0 additions & 1 deletion cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ impl Display for Error {
Error::NoFlagSupplied(subcommand) => write!(f, "The subcommand {} requires atleast one flag. Check `aries-cli {} --help for the available options.", subcommand, subcommand),
Error::RequiredAttributes => write!(f, "Creating a schema requires at least one attribute. Please supply them via the --attributes flag."),
Error::InvalidConfigurationStructure => write!(f, "Invalid configuration structure. Please make sure you have a valid configuration file."),

}
}
}

0 comments on commit 3f398c2

Please sign in to comment.