Fix error handling

This commit is contained in:
Richard Roberson 2025-01-26 14:48:45 -07:00
parent 816690360e
commit b5e6a341ba
2 changed files with 4 additions and 12 deletions

View file

@ -5,7 +5,7 @@ import { Transition, TransitionChild, DialogPanel, DialogTitle } from '@headless
import { Fragment, useState } from 'react';
export function DocumentList() {
const { documents, removeDocument, isLoading, error } = usePDF();
const { documents, removeDocument, isLoading } = usePDF();
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
const [documentToDelete, setDocumentToDelete] = useState<{ id: string; name: string } | null>(null);
@ -29,14 +29,6 @@ export function DocumentList() {
);
}
if (error) {
return (
<div className="w-full text-center text-red-500">
{error}
</div>
);
}
if (documents.length === 0) {
return (
<div className="w-full text-center text-muted">

View file

@ -9,7 +9,7 @@ interface PDFUploaderProps {
}
export function PDFUploader({ className = '' }: PDFUploaderProps) {
const { addDocument, error: contextError } = usePDF();
const { addDocument } = usePDF();
const [isUploading, setIsUploading] = useState(false);
const [error, setError] = useState<string | null>(null);
@ -21,13 +21,13 @@ export function PDFUploader({ className = '' }: PDFUploaderProps) {
try {
await addDocument(file);
} catch (err) {
setError(contextError || 'Failed to upload PDF. Please try again.');
setError('Failed to upload PDF. Please try again.');
console.error('Upload error:', err);
} finally {
setIsUploading(false);
}
}
}, [addDocument, contextError]);
}, [addDocument]);
const { getRootProps, getInputProps, isDragActive } = useDropzone({
onDrop,