Navigate to LoadError when node view isn't able to load

This can have multiple reasons, interface has added a new property but
httpds haven't updated yet.
Other issues with some specific endpoints that return a 500 and we can't
load it.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2023-10-06 14:18:48 +02:00
parent 288f55da76
commit b12a9495cb
+13 -3
View File
@@ -1,5 +1,8 @@
import type { BaseUrl, CommitHeader, Project } from "@httpd-client";
import type { NotFoundRoute } from "@app/lib/router/definitions";
import type {
LoadErrorRoute,
NotFoundRoute,
} from "@app/lib/router/definitions";
import type { WeeklyActivity } from "@app/lib/commit";
import { HttpdClient } from "@httpd-client";
@@ -89,7 +92,7 @@ export function nodePath(baseUrl: BaseUrl) {
export async function loadNodeRoute(
params: NodesRouteParams,
): Promise<NodesLoadedRoute | NotFoundRoute> {
): Promise<NodesLoadedRoute | NotFoundRoute | LoadErrorRoute> {
const api = new HttpdClient(params.baseUrl);
try {
const projectPageIndex = 0;
@@ -117,7 +120,14 @@ export async function loadNodeRoute(
},
};
} else {
throw error;
return {
resource: "loadError",
params: {
title: "Not able to load this node",
errorMessage: error.message,
stackTrace: error.stackTrace,
},
};
}
}
}