File tree Expand file tree Collapse file tree 3 files changed +4
-4
lines changed
Expand file tree Collapse file tree 3 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ def from_bytes(cls, file: BytesIO) -> "PdfFile":
8888class TxtFile (File ):
8989 @classmethod
9090 def from_bytes (cls , file : BytesIO ) -> "TxtFile" :
91- text = file .read ().decode ("utf-8" )
91+ text = file .read ().decode ("utf-8" , errors = "replace" )
9292 text = strip_consecutive_newlines (text )
9393 file .seek (0 )
9494 doc = Document (page_content = text .strip ())
Original file line number Diff line number Diff line change 6363try :
6464 file = read_file (uploaded_file )
6565except Exception as e :
66- display_file_read_error (e )
66+ display_file_read_error (e , file_name = uploaded_file . name )
6767
6868chunked_file = chunk_file (file , chunk_size = 300 , chunk_overlap = 0 )
6969
Original file line number Diff line number Diff line change @@ -36,9 +36,9 @@ def is_file_valid(file: File) -> bool:
3636 return True
3737
3838
39- def display_file_read_error (e : Exception ) -> NoReturn :
39+ def display_file_read_error (e : Exception , file_name : str ) -> NoReturn :
4040 st .error ("Error reading file. Make sure the file is not corrupted or encrypted" )
41- logger .error (f"{ e .__class__ .__name__ } : { e } " )
41+ logger .error (f"{ e .__class__ .__name__ } : { e } . Extension: { file_name . split ( '.' )[ - 1 ] } " )
4242 st .stop ()
4343
4444
You can’t perform that action at this time.
0 commit comments