fix flows

This commit is contained in:
JMARyA 2024-09-13 14:17:55 +02:00
parent 7b6d58be33
commit e26c8b3469
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
7 changed files with 52 additions and 35 deletions

View file

@ -123,8 +123,7 @@ pub async fn end_flow_route(id: &str, form: Json<EndFlow>) -> FallibleApiRespons
.ok_or_else(|| api_error("Flow not found"))?;
if let Some(produced) = &form.produced {
// todo : add transactions
let prod = flow.end_with_produce(produced).await;
let prod = flow.end_with_produce(produced).await?;
Ok(json!({"produced": prod}))
} else {
flow.end().await;

View file

@ -1,5 +1,5 @@
mod demand;
mod error;
pub mod error;
mod location;
mod stat;
mod supply;

View file

@ -6,10 +6,10 @@ use serde_json::json;
pub mod flow;
pub mod item;
type ApiError = BadRequest<serde_json::Value>;
pub type ApiError = BadRequest<serde_json::Value>;
type FallibleApiResponse = Result<serde_json::Value, ApiError>;
fn api_error(msg: &str) -> ApiError {
pub fn api_error(msg: &str) -> ApiError {
BadRequest(json!({
"error": msg
}))