Log error if failed to fetch remote image (#5393)
* I cant catch an error in the loadRemoteImage function when the fetch function occurs error * I cant catch an error in the loadRemoteImage function when the fetch function occurs error * fix ssg file Co-authored-by: wuls <linsheng.wu@beantechs.com> Co-authored-by: Okiki Ojo <okikio.dev@gmail.com>
This commit is contained in:
parent
aa16b6cebc
commit
e2fb0c4ff2
3 changed files with 9 additions and 2 deletions
5
.changeset/tough-doors-shop.md
Normal file
5
.changeset/tough-doors-shop.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/image': patch
|
||||
---
|
||||
|
||||
Log error if failed to fetch remote image
|
|
@ -73,7 +73,8 @@ async function loadRemoteImage(src: string) {
|
|||
data: Buffer.from(await res.arrayBuffer()),
|
||||
expires: Date.now() + expires,
|
||||
};
|
||||
} catch {
|
||||
} catch (err: unknown) {
|
||||
console.error(err)
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ async function loadRemoteImage(src: URL) {
|
|||
}
|
||||
|
||||
return Buffer.from(await res.arrayBuffer());
|
||||
} catch {
|
||||
} catch (err: unknown) {
|
||||
console.error(err)
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue