fix: enhance error handling in build_flow and add error handling for Flow build (#3259)

* feat: add error handling for Flow build

The code changes in `buildUtils.ts` add error handling for the Flow build process. It includes a new case for handling errors in the switch statement, which displays the error message and triggers the `onBuildError` function. This change ensures that errors during the Flow build are properly handled and the build process is stopped.

* feat: enhance error handling in build_flow to capture and report HTTP exceptions in the flow building process
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-08-09 11:15:35 -03:00 committed by GitHub
commit d0484ba412
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View file

@ -356,10 +356,23 @@ async def build_flow(
except asyncio.CancelledError:
vertices_task.cancel()
return
except Exception as e:
if isinstance(e, HTTPException):
send_event("error", {"error": str(e.detail), "statusCode": e.status_code}, queue)
raise e
send_event("error", {"error": str(e)}, queue)
raise e
ids, vertices_to_run, graph = vertices_task.result()
else:
ids, vertices_to_run, graph = await build_graph_and_get_order()
try:
ids, vertices_to_run, graph = await build_graph_and_get_order()
except Exception as e:
if isinstance(e, HTTPException):
send_event("error", {"error": str(e.detail), "statusCode": e.status_code}, queue)
raise e
send_event("error", {"error": str(e)}, queue)
raise e
send_event("vertices_sorted", {"ids": ids, "to_run": vertices_to_run}, queue)
await client_consumed_queue.get()

View file

@ -264,6 +264,14 @@ export async function buildFlowVertices({
useFlowStore.getState().setIsBuilding(false);
return true;
}
case "error": {
const errorMessage = data.error;
console.log(data);
onBuildError!("Error Running Flow", [errorMessage], []);
buildResults.push(false);
useFlowStore.getState().setIsBuilding(false);
return true;
}
default:
return true;
}