Merge pull request #552 from automatisch/fix/expose-errors-as-execute-flow
fix: Expose errors within execute flow mutation
This commit is contained in:
@@ -24,7 +24,7 @@ const executeFlow = async (
|
|||||||
|
|
||||||
const flow = await untilStep.$relatedQuery('flow');
|
const flow = await untilStep.$relatedQuery('flow');
|
||||||
|
|
||||||
const data = await new Processor(flow, {
|
const executionStep = await new Processor(flow, {
|
||||||
untilStep,
|
untilStep,
|
||||||
testRun: true,
|
testRun: true,
|
||||||
}).run();
|
}).run();
|
||||||
@@ -33,7 +33,11 @@ const executeFlow = async (
|
|||||||
status: 'completed',
|
status: 'completed',
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data, step: untilStep };
|
if (executionStep.errorDetails) {
|
||||||
|
throw new Error(JSON.stringify(executionStep.errorDetails));
|
||||||
|
}
|
||||||
|
|
||||||
|
return { data: executionStep.dataOut, step: untilStep };
|
||||||
};
|
};
|
||||||
|
|
||||||
export default executeFlow;
|
export default executeFlow;
|
||||||
|
@@ -160,11 +160,7 @@ class Processor {
|
|||||||
.orderBy('created_at', 'desc')
|
.orderBy('created_at', 'desc')
|
||||||
.first();
|
.first();
|
||||||
|
|
||||||
if (lastExecutionStepFromFirstExecution.errorDetails) {
|
return lastExecutionStepFromFirstExecution;
|
||||||
return lastExecutionStepFromFirstExecution.errorDetails;
|
|
||||||
} else {
|
|
||||||
return lastExecutionStepFromFirstExecution?.dataOut;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getInitialTriggerData(step: Step) {
|
async getInitialTriggerData(step: Step) {
|
||||||
|
@@ -25,6 +25,19 @@ type TestSubstepProps = {
|
|||||||
step: IStep;
|
step: IStep;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function serializeErrors(graphQLErrors: any) {
|
||||||
|
return graphQLErrors?.map((error: Record<string, unknown>) => {
|
||||||
|
try {
|
||||||
|
return {
|
||||||
|
...error,
|
||||||
|
message: (<pre style={{ margin: 0 }}>{JSON.stringify(JSON.parse(error.message as string), null, 2)}</pre>),
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function TestSubstep(props: TestSubstepProps): React.ReactElement {
|
function TestSubstep(props: TestSubstepProps): React.ReactElement {
|
||||||
const {
|
const {
|
||||||
substep,
|
substep,
|
||||||
@@ -81,7 +94,7 @@ function TestSubstep(props: TestSubstepProps): React.ReactElement {
|
|||||||
<Collapse in={expanded} timeout="auto" unmountOnExit>
|
<Collapse in={expanded} timeout="auto" unmountOnExit>
|
||||||
<ListItem sx={{ pt: 2, pb: 3, flexDirection: 'column', alignItems: 'flex-start' }}>
|
<ListItem sx={{ pt: 2, pb: 3, flexDirection: 'column', alignItems: 'flex-start' }}>
|
||||||
{error?.graphQLErrors?.length && <Alert severity="error" sx={{ mb: 1, fontWeight: 500, width: '100%' }}>
|
{error?.graphQLErrors?.length && <Alert severity="error" sx={{ mb: 1, fontWeight: 500, width: '100%' }}>
|
||||||
{error?.graphQLErrors.map((error) => (<>{error.message}<br /></>))}
|
{serializeErrors(error.graphQLErrors).map((error: any) => (<div>{error.message}</div>))}
|
||||||
</Alert>}
|
</Alert>}
|
||||||
|
|
||||||
{hasNoOutput && (
|
{hasNoOutput && (
|
||||||
|
Reference in New Issue
Block a user