|
@@ -4,6 +4,7 @@ use actix_web::{
|
|
|
};
|
|
|
use ledger_utxo::{AccountId, AnyId, AssetDefinition, AssetManager, Status, TransactionId};
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
+use serde_json::json;
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
@@ -123,10 +124,11 @@ async fn get_balance(info: web::Path<AccountId>, ledger: web::Data<Ledger>) -> i
|
|
|
.collect::<Result<Vec<_>, _>>()
|
|
|
{
|
|
|
Ok(balances) => HttpResponse::Ok().json(balances),
|
|
|
- Err(e) => HttpResponse::BadRequest().json(e),
|
|
|
+ Err(err) => HttpResponse::InternalServerError()
|
|
|
+ .json(json!({ "text": err.to_string(), "err": err})),
|
|
|
}
|
|
|
}
|
|
|
- Err(e) => HttpResponse::BadRequest().json(e),
|
|
|
+ Err(err) => HttpResponse::BadRequest().json(json!({ "text": err.to_string(), "err": err})),
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -147,7 +149,9 @@ async fn get_info(info: web::Path<AnyId>, ledger: web::Data<Ledger>) -> impl Res
|
|
|
|
|
|
match result {
|
|
|
Ok(x) => x,
|
|
|
- Err(err) => HttpResponse::InternalServerError().json(err),
|
|
|
+ Err(err) => {
|
|
|
+ HttpResponse::InternalServerError().json(json!({ "text": err.to_string(), "err": err}))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -161,7 +165,7 @@ async fn deposit(item: web::Json<Deposit>, ledger: web::Data<Ledger>) -> impl Re
|
|
|
// For this example, we'll just echo the received item.
|
|
|
HttpResponse::Created().json(tx)
|
|
|
}
|
|
|
- Err(e) => HttpResponse::Created().json(e),
|
|
|
+ Err(err) => HttpResponse::BadRequest().json(json!({ "text": err.to_string(), "err": err})),
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -172,7 +176,9 @@ async fn create_transaction(
|
|
|
) -> impl Responder {
|
|
|
match item.into_inner().to_ledger_transaction(&ledger).await {
|
|
|
Ok(tx) => HttpResponse::Accepted().json(tx),
|
|
|
- Err(err) => HttpResponse::Created().json(err),
|
|
|
+ Err(err) => {
|
|
|
+ HttpResponse::InternalServerError().json(json!({ "text": err.to_string(), "err": err}))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -188,7 +194,9 @@ async fn update_status(
|
|
|
.await
|
|
|
{
|
|
|
Ok(tx) => HttpResponse::Accepted().json(tx),
|
|
|
- Err(err) => HttpResponse::Created().json(err),
|
|
|
+ Err(err) => {
|
|
|
+ HttpResponse::InternalServerError().json(json!({ "text": err.to_string(), "err": err}))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|