aboutsummaryrefslogtreecommitdiffstats
path: root/adenosine-cli
diff options
context:
space:
mode:
Diffstat (limited to 'adenosine-cli')
-rw-r--r--adenosine-cli/src/lib.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/adenosine-cli/src/lib.rs b/adenosine-cli/src/lib.rs
index 8ffeb88..a3f1dac 100644
--- a/adenosine-cli/src/lib.rs
+++ b/adenosine-cli/src/lib.rs
@@ -67,10 +67,17 @@ impl XrpcClient {
.get(format!("{}/xrpc/{}", self.host, nsid))
.query(&params)
.send()?;
+ // TODO: refactor this error handling stuff into single method
if res.status() == 400 {
let val: Value = res.json()?;
return Err(anyhow!(
- "XRPC Bad Request: {}",
+ "XRPC Bad Request (400): {}",
+ val["message"].as_str().unwrap_or("unknown")
+ ));
+ } else if res.status() == 500 {
+ let val: Value = res.json()?;
+ return Err(anyhow!(
+ "XRPC Internal Error (500): {}",
val["message"].as_str().unwrap_or("unknown")
));
}
@@ -93,7 +100,13 @@ impl XrpcClient {
if res.status() == 400 {
let val: Value = res.json()?;
return Err(anyhow!(
- "XRPC Bad Request: {}",
+ "XRPC Bad Request (400): {}",
+ val["message"].as_str().unwrap_or("unknown")
+ ));
+ } else if res.status() == 500 {
+ let val: Value = res.json()?;
+ return Err(anyhow!(
+ "XRPC Internal Error (500): {}",
val["message"].as_str().unwrap_or("unknown")
));
}
@@ -121,7 +134,13 @@ impl XrpcClient {
if res.status() == 400 {
let val: Value = res.json()?;
return Err(anyhow!(
- "XRPC Bad Request: {}",
+ "XRPC Bad Request (400): {}",
+ val["message"].as_str().unwrap_or("unknown")
+ ));
+ } else if res.status() == 500 {
+ let val: Value = res.json()?;
+ return Err(anyhow!(
+ "XRPC Internal Error (500): {}",
val["message"].as_str().unwrap_or("unknown")
));
}