mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Improve catching of errors when loading routes
- Handle ResponseParseErros, ResponseErrors and normal errors differently. - Show them all in the same `LoadError` view - Add a subtitle to give users some more information on what could have gone wrong. - Add more properties to the copyable error message to make debugging easier.
This commit is contained in:
+3
-3
@@ -122,8 +122,8 @@ function setTitle(loadedRoute: LoadedRoute) {
|
||||
|
||||
if (loadedRoute.resource === "booting" || loadedRoute.resource === "home") {
|
||||
title.push("Radicle");
|
||||
} else if (loadedRoute.resource === "loadError") {
|
||||
title.push("Load error");
|
||||
} else if (loadedRoute.resource === "error") {
|
||||
title.push("Error");
|
||||
title.push("Radicle");
|
||||
} else if (loadedRoute.resource === "notFound") {
|
||||
title.push("Page not found");
|
||||
@@ -259,7 +259,7 @@ export function routeToPath(route: Route): string {
|
||||
} else if (
|
||||
route.resource === "booting" ||
|
||||
route.resource === "notFound" ||
|
||||
route.resource === "loadError"
|
||||
route.resource === "error"
|
||||
) {
|
||||
return "";
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import type { HomeRoute, HomeLoadedRoute } from "@app/views/home/router";
|
||||
import type {
|
||||
ResponseParseError,
|
||||
ResponseError,
|
||||
} from "@httpd-client/lib/fetcher";
|
||||
import type {
|
||||
ProjectLoadedRoute,
|
||||
ProjectRoute,
|
||||
@@ -29,19 +33,19 @@ interface SessionRoute {
|
||||
};
|
||||
}
|
||||
|
||||
export interface LoadErrorRoute {
|
||||
resource: "loadError";
|
||||
export interface ErrorRoute {
|
||||
resource: "error";
|
||||
params: {
|
||||
title: string;
|
||||
errorMessage: string;
|
||||
stackTrace: string;
|
||||
description: string;
|
||||
error: Error | ResponseError | ResponseParseError;
|
||||
};
|
||||
}
|
||||
|
||||
export type Route =
|
||||
| BootingRoute
|
||||
| HomeRoute
|
||||
| LoadErrorRoute
|
||||
| ErrorRoute
|
||||
| NotFoundRoute
|
||||
| ProjectRoute
|
||||
| NodesRoute
|
||||
@@ -50,7 +54,7 @@ export type Route =
|
||||
export type LoadedRoute =
|
||||
| BootingRoute
|
||||
| HomeLoadedRoute
|
||||
| LoadErrorRoute
|
||||
| ErrorRoute
|
||||
| NotFoundRoute
|
||||
| ProjectLoadedRoute
|
||||
| NodesLoadedRoute
|
||||
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
import type { Comment } from "@httpd-client";
|
||||
import type { BaseUrl, Comment } from "@httpd-client";
|
||||
|
||||
import md5 from "md5";
|
||||
import bs58 from "bs58";
|
||||
@@ -93,6 +93,10 @@ export function formatEditedCaption(lastEdit: Comment["edits"][0]) {
|
||||
} edited ${formatTimestamp(lastEdit.timestamp / 1000)}`;
|
||||
}
|
||||
|
||||
export function baseUrlToUrl(baseUrl: BaseUrl): URL {
|
||||
return new URL(`${baseUrl.scheme}://${baseUrl.hostname}:${baseUrl.port}`);
|
||||
}
|
||||
|
||||
// Generates a publicly shareable link.
|
||||
export function formatPublicExplorer(
|
||||
publicExplorer: string,
|
||||
|
||||
Reference in New Issue
Block a user