Skip to content

Commit 88e09cc

Browse files
authored
fix: properly handle request errors (#260)
1 parent 949b8d2 commit 88e09cc

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

plugins/typescript/src/templates/fetcher.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,8 @@ export async function ${camel(prefix)}Fetch<
109109
: "Unexpected error"
110110
};
111111
}
112-
113-
throw error;
114112
}
115-
116-
if (response.headers.get('content-type')?.includes('json')) {
113+
else if (response.headers.get('content-type')?.includes('json')) {
117114
return await response.json();
118115
} else {
119116
// if it is not a json response, assume it is a blob and cast it to TData
@@ -128,6 +125,7 @@ export async function ${camel(prefix)}Fetch<
128125
};
129126
throw errorObject;
130127
}
128+
throw error;
131129
}
132130
133131
const resolveUrl = (

0 commit comments

Comments
 (0)