fix: display specific error message when previewing file error #868 (#869)

### What problem does this PR solve?

fix: display specific error message when previewing file error  #868


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2024-05-22 11:54:32 +08:00
committed by GitHub
parent 3cae87a902
commit b62a20816e
4 changed files with 39 additions and 17 deletions

View File

@ -1,12 +1,14 @@
import { Skeleton } from 'antd';
import { PdfHighlighter, PdfLoader } from 'react-pdf-highlighter';
import FileError from '../file-error';
import { useCatchError } from '../hooks';
interface IProps {
url: string;
}
const DocumentPreviewer = ({ url }: IProps) => {
const PdfPreviewer = ({ url }: IProps) => {
const { error } = useCatchError(url);
const resetHash = () => {};
return (
@ -15,7 +17,7 @@ const DocumentPreviewer = ({ url }: IProps) => {
url={url}
beforeLoad={<Skeleton active />}
workerSrc="/pdfjs-dist/pdf.worker.min.js"
errorMessage={<FileError></FileError>}
errorMessage={<FileError>{error}</FileError>}
onError={(e) => {
console.warn(e);
}}
@ -40,4 +42,4 @@ const DocumentPreviewer = ({ url }: IProps) => {
);
};
export default DocumentPreviewer;
export default PdfPreviewer;