mirror of
https://github.com/LukeHagar/crossws.git
synced 2025-12-09 20:37:49 +00:00
feat: allow throwing error with .response prop in upgrade (#113)
Co-authored-by: Pooya Parsa <pooya@pi0.io>
This commit is contained in:
10
src/hooks.ts
10
src/hooks.ts
@@ -66,8 +66,12 @@ export class AdapterHookable {
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Response) {
|
||||
return { context, endResponse: error };
|
||||
const errResponse = (error as { response: Response }).response || error;
|
||||
if (errResponse instanceof Response) {
|
||||
return {
|
||||
context,
|
||||
endResponse: errResponse,
|
||||
};
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
@@ -96,6 +100,8 @@ export type UpgradeRequest =
|
||||
headers: Headers;
|
||||
};
|
||||
|
||||
export type UpgradeError = Response | { readonly response: Response };
|
||||
|
||||
export interface Hooks {
|
||||
/** Upgrading */
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user