Skip to content

Commit 7d62e97

Browse files
committed
fix: throw better errors
1 parent 766a814 commit 7d62e97

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/CloudConvert.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,14 @@ export default class CloudConvert {
153153
// @ts-expect-error incorrect types in @types/node@20
154154
duplex: 'half'
155155
});
156+
if (!res.ok) {
157+
// @ts-expect-error cause not present in types yet
158+
throw new Error(res.statusText, { cause: res });
159+
}
160+
156161
if (
157-
!res.ok ||
158162
res.headers.get('Content-Type')?.toLowerCase() !==
159-
'application/json'
163+
'application/json'
160164
) {
161165
return undefined;
162166
}

0 commit comments

Comments
 (0)