fix some bugs and enhance error handling
This commit is contained in:
@@ -21,14 +21,13 @@ export function runMission(id) {
|
||||
"run_mission",
|
||||
mission
|
||||
);
|
||||
if (error) {
|
||||
throw new Error(message);
|
||||
if (!error) {
|
||||
await prisma.mission.update({
|
||||
where: { id },
|
||||
data: { result },
|
||||
});
|
||||
}
|
||||
const missionWithResult = prisma.mission.update({
|
||||
where: { id },
|
||||
data: { result },
|
||||
});
|
||||
return missionWithResult;
|
||||
return { result, error, message };
|
||||
} else {
|
||||
throw Error("Mission doest not exist");
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ load_dotenv()
|
||||
|
||||
process_type = {
|
||||
"SEQUENTIAL": Process.sequential,
|
||||
"HIERARTICAL": Process.hierarchical,
|
||||
"HIERARCHICAL": Process.hierarchical,
|
||||
}
|
||||
|
||||
tool_dict = {
|
||||
@@ -74,12 +74,7 @@ def run_mission(mission):
|
||||
)
|
||||
|
||||
result = crew.kickoff()
|
||||
return {
|
||||
"result": result
|
||||
}
|
||||
return {"result": result}
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return ({
|
||||
"error": True,
|
||||
"message": str(e)
|
||||
})
|
||||
return {"error": True, "message": str(e)}
|
||||
|
||||
@@ -50,6 +50,12 @@ const typeDefs = `#graphql
|
||||
result: String
|
||||
}
|
||||
|
||||
type RunMissionResult {
|
||||
result: String
|
||||
error: Boolean
|
||||
message: String
|
||||
}
|
||||
|
||||
enum MissionProcess {
|
||||
SEQUENTIAL
|
||||
HIERARCHICAL
|
||||
@@ -103,7 +109,7 @@ const typeDefs = `#graphql
|
||||
|
||||
deleteMission(id: Int!): DeleteOutput
|
||||
|
||||
runMission(id: Int!): Mission
|
||||
runMission(id: Int!): RunMissionResult
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user