Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃 FE error handling #1156

Merged
merged 4 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions next/src/pages/workflow/[workflow].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ const WorkflowPage: NextPage = () => {
const { session } = useAuth({ protectedRoute: true });
const { query } = useRouter();

const handleClick = async () => {
try {
await saveWorkflow();
window.alert('Workflow saved successfully!');
} catch (error) {
window.alert('An error occurred while saving the workflow. ' + error);
}
};


const { nodesModel, edgesModel, selectedNode, saveWorkflow, createNode, updateNode, members } =
useWorkflow(query.workflow as string, session);

Expand Down Expand Up @@ -53,9 +63,7 @@ const WorkflowPage: NextPage = () => {
<div className="absolute bottom-4 right-4 flex flex-row items-center justify-center gap-2">
<PrimaryButton
icon={<FaSave size="15" />}
onClick={() => {
saveWorkflow().catch(console.error);
}}
onClick={handleClick}
>
Save
</PrimaryButton>
Expand Down
2 changes: 1 addition & 1 deletion next/src/services/fetch-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const put = async <T extends z.ZodTypeAny>(
});

if (!response.ok) {
throw new Error("Request failed");
throw new Error(response.statusText);
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-return
Expand Down
2 changes: 1 addition & 1 deletion next/src/services/workflow/workflowApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class WorkflowApi {
async update(id: string, data: Workflow) {
return await put(
`/api/workflow/${id}`,
PresignedPostSchema,
z.any(),
data,
this.accessToken,
this.organizationId
Expand Down