attempting to resolve type issues

This commit is contained in:
Luke Hagar
2025-02-02 14:02:35 -06:00
parent bc55c9765f
commit f4bf13cc38
2 changed files with 20 additions and 11 deletions

View File

@@ -66,11 +66,14 @@ export class AdapterHookable {
};
}
} catch (error) {
const errResponse = (error as { response: Response }).response || error;
if (errResponse instanceof Response) {
if (
error instanceof Response ||
(error && typeof error === "object" && "response" in error && typeof error.response === "function")
) {
const response = error instanceof Response ? error : (error as { response: () => Response }).response();
return {
context,
endResponse: errResponse,
endResponse: response,
};
}
throw error;