implement fetch and external resource request apis

This commit is contained in:
AAGaming
2024-05-04 22:39:30 -04:00
parent 2a22f000c1
commit 14ea7b964f
14 changed files with 609 additions and 525 deletions
+4 -4
View File
@@ -30,7 +30,7 @@ interface ReplyMessage {
interface ErrorMessage {
type: MessageType.ERROR;
error: { name: string; message: string; traceback: string | null };
error: { name: string; error: string; traceback: string | null };
id: number;
}
@@ -40,8 +40,8 @@ interface ErrorMessage {
export class PyError extends Error {
pythonTraceback: string | null;
constructor(name: string, message: string, traceback: string | null) {
super(message);
constructor(name: string, error: string, traceback: string | null) {
super(error);
this.name = `Python ${name}`;
if (traceback) {
// traceback will always start with `Traceback (most recent call last):`
@@ -142,7 +142,7 @@ export class WSRouter extends Logger {
case MessageType.ERROR:
if (this.runningCalls.has(data.id)) {
let err = new PyError(data.error.name, data.error.message, data.error.traceback);
let err = new PyError(data.error.name, data.error.error, 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);