generated from polymech/site-template
15 lines
465 B
JavaScript
15 lines
465 B
JavaScript
// @ts-check
|
|
import { supportedImageTypes } from "../../utils/runtimeChecks.js";
|
|
|
|
export default function throwErrorIfUnsupported(src, ext) {
|
|
if (!ext && typeof ext !== "string") {
|
|
throw new Error(`Failed to load ${src}; Invalid image format`);
|
|
}
|
|
|
|
if (ext && !supportedImageTypes.includes(ext.toLowerCase())) {
|
|
throw new Error(
|
|
`Failed to load ${src}; Invalid image format ${ext} or the format is not supported by astro-imagetools`
|
|
);
|
|
}
|
|
}
|