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:
wulinsheng123 2022-11-17 05:55:48 +08:00 committed by GitHub
parent aa16b6cebc
commit e2fb0c4ff2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/image': patch
---
Log error if failed to fetch remote image

View file

@ -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;
}
}

View file

@ -14,7 +14,8 @@ async function loadRemoteImage(src: URL) {
}
return Buffer.from(await res.arrayBuffer());
} catch {
} catch (err: unknown) {
console.error(err)
return undefined;
}
}