add try catch wrapper
This commit is contained in:
parent
8a6f7e54ab
commit
701a66d6ce
|
@ -1,6 +1,7 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { imageBitmapToBlob } from 'utils/image';
|
||||
import { logError } from 'utils/sentry';
|
||||
import { getBlobFromCache } from 'utils/storage/cache';
|
||||
|
||||
export const Image = styled.img``;
|
||||
|
@ -26,6 +27,7 @@ export function ImageCacheView(props: { url: string; cacheName: string }) {
|
|||
let didCancel = false;
|
||||
|
||||
async function loadImage() {
|
||||
try {
|
||||
let blob: Blob;
|
||||
if (!props.url || !props.cacheName) {
|
||||
blob = undefined;
|
||||
|
@ -34,8 +36,10 @@ export function ImageCacheView(props: { url: string; cacheName: string }) {
|
|||
}
|
||||
|
||||
!didCancel && setImageBlob(blob);
|
||||
} catch (e) {
|
||||
logError(e, 'ImageCacheView useEffect failed');
|
||||
}
|
||||
}
|
||||
|
||||
loadImage();
|
||||
return () => {
|
||||
didCancel = true;
|
||||
|
|
Loading…
Reference in a new issue