Skip to content

Commit

Permalink
better error formatting on /publish-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Feb 20, 2024
1 parent 7811c03 commit d547c6d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions editor.planx.uk/src/routes/views/publishedPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FlowGraph } from "@opensystemslab/planx-core/types";
import axios from "axios";
import axios, { AxiosError } from "axios";
import { NaviRequest, NotFoundError } from "navi";
import { useStore } from "pages/FlowEditor/lib/store";
import PublicLayout from "pages/layout/PublicLayout";
Expand Down Expand Up @@ -51,6 +51,13 @@ const fetchFlattenedFlowData = async (flowId: string): Promise<FlowGraph> => {
return data;
} catch (error) {
console.log(error);
throw new NotFoundError();
if (error instanceof AxiosError) {
alert(
`Cannot open /publish-preview, navigate back to the graph to keep editing. \n\n${error.response?.data?.error}`,
);
throw new NotFoundError();
} else {
throw new NotFoundError();
}
}
};

0 comments on commit d547c6d

Please sign in to comment.