mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 10:19:08 +00:00
Better way to throw websocket exceptions
This commit is contained in:
@@ -33,9 +33,10 @@ export class HTTPError extends Error {
|
|||||||
headers: HTTPErrorHeadersType;
|
headers: HTTPErrorHeadersType;
|
||||||
response?: unknown;
|
response?: unknown;
|
||||||
stack?: string;
|
stack?: string;
|
||||||
|
cause?: unknown;
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
super(`${message}; code: ${options.code}`);
|
super(`${message}; code: ${options.code}`, { cause: options.cause });
|
||||||
|
|
||||||
const { code: providedCode, headers, response, stack } = options;
|
const { code: providedCode, headers, response, stack } = options;
|
||||||
|
|
||||||
|
|||||||
@@ -100,17 +100,16 @@ export function connect<Resource extends IResource>({
|
|||||||
reject(translatedError);
|
reject(translatedError);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('connectFailed', e => {
|
client.on('connectFailed', originalErr => {
|
||||||
Timers.clearTimeout(timer);
|
Timers.clearTimeout(timer);
|
||||||
|
|
||||||
reject(
|
const err = new HTTPError('connectResource: connectFailed', {
|
||||||
new HTTPError('connectResource: connectFailed', {
|
|
||||||
code: -1,
|
code: -1,
|
||||||
headers: {},
|
headers: {},
|
||||||
response: e.toString(),
|
|
||||||
stack,
|
stack,
|
||||||
})
|
cause: originalErr,
|
||||||
);
|
});
|
||||||
|
reject(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
return new AbortableProcess<Resource>(
|
return new AbortableProcess<Resource>(
|
||||||
|
|||||||
Reference in New Issue
Block a user