summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorParty Wumpus <48649272+PartyWumpus@users.noreply.github.com>2024-02-22 16:38:50 +0000
committerParty Wumpus <48649272+PartyWumpus@users.noreply.github.com>2024-02-22 16:38:50 +0000
commit89a4a69f6da706a0cd8c4036bc1aa4c6e44f6e11 (patch)
treee6e0409dd6efa7eaba08bff0bcd50143dcda1d24 /frontend
parenta449181802f05c0d1bd1a318741ce347e993d6f7 (diff)
downloaddecky-loader-89a4a69f6da706a0cd8c4036bc1aa4c6e44f6e11.tar.gz
decky-loader-89a4a69f6da706a0cd8c4036bc1aa4c6e44f6e11.zip
make frontend -> backend errors actually work
Diffstat (limited to 'frontend')
-rw-r--r--frontend/src/components/settings/pages/testing/index.tsx10
-rw-r--r--frontend/src/wsrouter.ts17
2 files changed, 22 insertions, 5 deletions
diff --git a/frontend/src/components/settings/pages/testing/index.tsx b/frontend/src/components/settings/pages/testing/index.tsx
index cdf51c71..4fe0f240 100644
--- a/frontend/src/components/settings/pages/testing/index.tsx
+++ b/frontend/src/components/settings/pages/testing/index.tsx
@@ -70,8 +70,14 @@ export default function TestingVersionList() {
<Focusable style={{ height: '40px', marginLeft: 'auto', display: 'flex' }}>
<DialogButton
style={{ height: '40px', minWidth: '60px', marginRight: '10px' }}
- onClick={() => {
- downloadTestingVersion(version.id, version.head_sha);
+ onClick={async () => {
+ try {
+ await downloadTestingVersion(version.id, version.head_sha);
+ } catch (e) {
+ if (e instanceof Error) {
+ DeckyPluginLoader.toaster.toast({ title: 'Error Installing PR', body: e.message });
+ }
+ }
setSetting('branch', UpdateBranch.Testing);
}}
>
diff --git a/frontend/src/wsrouter.ts b/frontend/src/wsrouter.ts
index 37df4262..e3a6900b 100644
--- a/frontend/src/wsrouter.ts
+++ b/frontend/src/wsrouter.ts
@@ -30,10 +30,20 @@ interface ReplyMessage {
interface ErrorMessage {
type: MessageType.ERROR;
- error: any;
+ error: { name: string; message: string; traceback: string | null };
id: number;
}
+export class PyError extends Error {
+ pythonTraceback: string | null;
+
+ constructor(name: string, message: string, traceback: string | null) {
+ super(message);
+ this.name = `Python ${name}`;
+ this.pythonTraceback = traceback;
+ }
+}
+
interface EventMessage {
type: MessageType.EVENT;
event: string;
@@ -45,7 +55,7 @@ type Message = CallMessage | ReplyMessage | ErrorMessage | EventMessage;
// Helper to resolve a promise from the outside
interface PromiseResolver<T> {
resolve: (res: T) => void;
- reject: (error: string) => void;
+ reject: (error: PyError) => void;
promise: Promise<T>;
}
@@ -124,7 +134,8 @@ export class WSRouter extends Logger {
case MessageType.ERROR:
if (this.runningCalls.has(data.id)) {
- this.runningCalls.get(data.id)!.reject(data.error);
+ let err = new PyError(data.error.name, data.error.message, data.error.traceback);
+ this.runningCalls.get(data.id)!.reject(err);
this.runningCalls.delete(data.id);
this.debug(`Rejected PY call ${data.id} with error`, data.error);
}