mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-25 23:46:51 +00:00
emit Error objects from socket 'error' events
main tightened the socket error contract to pass an Error (see types/modules/networking.d.ts, which documents the reason as `error.message`); the epoxy rewrite still emitted a bare string, matching the older `(reason: string)` declaration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
Neal Shah
co-authored by
Claude Opus 5
parent
6b23e7d7ed
commit
29456a24d5
@@ -19,12 +19,12 @@ function normalizeWriteData (data) {
|
||||
throw new Error('Invalid data type (not TypedArray, ArrayBuffer or String).');
|
||||
}
|
||||
|
||||
function normalizeErrorReason (reason) {
|
||||
function normalizeError (reason) {
|
||||
if ( reason instanceof Error ) {
|
||||
return reason.message;
|
||||
return reason;
|
||||
}
|
||||
|
||||
return String(reason);
|
||||
return new Error(String(reason));
|
||||
}
|
||||
|
||||
export class PSocket extends EventListener {
|
||||
@@ -236,7 +236,7 @@ export class PSocket extends EventListener {
|
||||
return;
|
||||
}
|
||||
|
||||
this.emit('error', normalizeErrorReason(reason));
|
||||
this.emit('error', normalizeError(reason));
|
||||
this.#closing = true;
|
||||
void this.#closeStreams(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user