From ee08b2b352ec427195baeeef6a781f7be8a31013 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 30 Jul 2022 01:10:01 +0200 Subject: [PATCH] more errors --- backend/src/jobs.rs | 2 +- backend/src/worker_flow.rs | 10 ++++++++-- frontend/src/lib/script_helpers.ts | 10 +++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/backend/src/jobs.rs b/backend/src/jobs.rs index 029fef85e2..68d9aa3ff3 100644 --- a/backend/src/jobs.rs +++ b/backend/src/jobs.rs @@ -1255,7 +1255,7 @@ pub async fn add_completed_job_error( false, false, Some(output_map.clone()), - format!("{}\n{}", logs, e.to_string()), + format!("\n{}\n{}", logs, e.to_string()), ) .await?; Ok((a, output_map)) diff --git a/backend/src/worker_flow.rs b/backend/src/worker_flow.rs index d38db4aeb6..3e9700d72f 100644 --- a/backend/src/worker_flow.rs +++ b/backend/src/worker_flow.rs @@ -124,7 +124,12 @@ pub async fn update_flow_status_after_job_completion( .bind(serde_json::json!(step_counter)) .bind(flow) .fetch_one(&mut tx) - .await?; + .await + .map_err(|e| { + Error::InternalErr(format!( + "error during retrieval of stop_early_expr from state: {e}" + )) + })?; tracing::debug!("UPDATE: {:?}", new_status); @@ -222,7 +227,7 @@ async fn skip_loop_failures<'c>( flow: Uuid, step: i32, tx: &mut sqlx::Transaction<'c, sqlx::Postgres>, -) -> Result, sqlx::Error> { +) -> Result, Error> { sqlx::query_as( " SELECT (raw_flow->'modules'->$1->'value'->>'skip_failures')::bool @@ -235,6 +240,7 @@ async fn skip_loop_failures<'c>( .fetch_one(tx) .await .map(|(v,)| v) + .map_err(|e| Error::InternalErr(format!("error during retrieval of skip_loop_failures: {e}"))) } async fn compute_stop_early( diff --git a/frontend/src/lib/script_helpers.ts b/frontend/src/lib/script_helpers.ts index 690d8e37cc..b0ba01b6c7 100644 --- a/frontend/src/lib/script_helpers.ts +++ b/frontend/src/lib/script_helpers.ts @@ -52,15 +52,15 @@ export async function main() { // let state = wmill.getInternalState() // 2. Get the actual state from the external service // let newState = await (await fetch('https://hacker-news.firebaseio.com/v0/topstories.json')).json() - // console.log(newState) - // 3. Compare the two states and update the internal state if necessary + // 3. Compare the two states and update the internal state // wmill.setInternalState(newState) // 4. Return the new ros - // return newState - state + // return range from (state to newState) - // You may refer to each row/value returned by the trigger script using - // flow_input._value return [1,2,3] + + // In subsequent scripts, you may refer to each row/value returned by the trigger script using + // 'flow_input._value' } `