Skip to content

Commit

Permalink
catch fetch exception
Browse files Browse the repository at this point in the history
  • Loading branch information
karwosts committed Dec 19, 2024
1 parent d87bf9a commit 95156b8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/ha-picture-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,16 @@ export class HaPictureUpload extends LitElement {
if (mediaId) {
if (this.crop) {
const url = generateImageThumbnailUrl(mediaId, undefined, true);
const response = await fetch(url);
const data = await response.blob();
let data;
try {
const response = await fetch(url);
data = await response.blob();
} catch (err: any) {
showAlertDialog(this, {
text: err.toString(),
});
return;
}
const metadata = {
type: pickedMedia.item.media_content_type,
};
Expand Down

0 comments on commit 95156b8

Please sign in to comment.