improve error handling
This commit is contained in:
@@ -685,7 +685,7 @@ def main(error, port):
|
||||
json!({
|
||||
"recv": 42,
|
||||
"from failure module": {
|
||||
"error": "Error during execution of the script:\n\nTraceback (most recent call last):\n File \"/tmp/main.py\", line 15, in <module>\n res = inner_script.main(**kwargs)\n File \"/tmp/inner.py\", line 5, in main\n return sock.recv(1)[0]\nIndexError: index out of range",
|
||||
"error": "Traceback (most recent call last):\n File \"/tmp/main.py\", line 15, in <module>\n res = inner_script.main(**kwargs)\n File \"/tmp/inner.py\", line 5, in main\n return sock.recv(1)[0]\nIndexError: index out of range",
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -2083,7 +2083,7 @@ async fn test_branchall_skip_failure(db: Pool<Postgres>) {
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
serde_json::json!([{"error": "Error during execution of the script:\n\nerror: Uncaught (in promise) Error: failure\nexport function main(){ throw Error('failure') }\n ^\n at main (file:///tmp/inner.ts:1:31)\n at run (file:///tmp/main.ts:9:26)\n at file:///tmp/main.ts:14:1"}, [1,3]])
|
||||
serde_json::json!([{"error": "error: Uncaught (in promise) Error: failure\nexport function main(){ throw Error('failure') }\n ^\n at main (file:///tmp/inner.ts:1:31)\n at run (file:///tmp/main.ts:9:26)\n at file:///tmp/main.ts:14:1"}, [1,3]])
|
||||
);
|
||||
|
||||
let flow: FlowValue = serde_json::from_value(json!({
|
||||
|
||||
@@ -875,11 +875,13 @@ async fn handle_queued_job(
|
||||
.split("CODE EXECUTION ---")
|
||||
.last()
|
||||
.unwrap_or(&logs);
|
||||
format!("Error during execution of the script:\n{}", log_lines)
|
||||
log_lines.to_string().trim().to_string()
|
||||
}
|
||||
err @ _ => format!("error before termination: {err:#?}"),
|
||||
};
|
||||
|
||||
tracing::info!("job {} failed: {}", job.id, error_message);
|
||||
|
||||
let (_, output_map) = add_completed_job_error(
|
||||
db,
|
||||
&job,
|
||||
|
||||
@@ -303,7 +303,6 @@ pub async fn update_flow_status_after_job_completion(
|
||||
.fetch_one(&mut tx)
|
||||
.await?;
|
||||
|
||||
tracing::info!("setting failure module for flow XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX {parent_module:?}");
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE queue
|
||||
@@ -687,13 +686,19 @@ async fn transform_input(
|
||||
}
|
||||
}
|
||||
|
||||
let lresult = last_result.clone();
|
||||
let error = if let Some(error) = lresult.as_object() {
|
||||
error.get("error")
|
||||
} else {
|
||||
None
|
||||
};
|
||||
for (key, val) in input_transforms.into_iter() {
|
||||
match val {
|
||||
InputTransform::Static { value: _ } => (),
|
||||
InputTransform::Javascript { expr } => {
|
||||
let flow_input = flow_args.clone().unwrap_or_else(|| json!({}));
|
||||
let previous_result = last_result.clone();
|
||||
let context = vec![
|
||||
let mut context = vec![
|
||||
("params".to_string(), json!(mapped)),
|
||||
("previous_result".to_string(), previous_result),
|
||||
("flow_input".to_string(), flow_input),
|
||||
@@ -705,6 +710,10 @@ async fn transform_input(
|
||||
("approvers".to_string(), json!(approvers.clone())),
|
||||
];
|
||||
|
||||
if error.is_some() {
|
||||
context.push(("error".to_string(), error.unwrap().clone()));
|
||||
}
|
||||
|
||||
let v = eval_timeout(
|
||||
expr.to_string(),
|
||||
context,
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
<div class="overflow-y-auto mb-2">
|
||||
<ObjectViewer
|
||||
pureViewer={!$propPickerConfig}
|
||||
json={{ previous_result: { error: 'The error to handle' } }}
|
||||
json={{ error: 'The error to handle' }}
|
||||
on:select
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user