@@ -48,12 +48,13 @@ import Papa from 'papaparse'
4848const $readCSV = async ( file : any , options ?: CsvInputOptionsBrowser ) : Promise < DataFrame > => {
4949 const frameConfig = options ?. frameConfig || { }
5050
51- return new Promise ( resolve => {
51+ return new Promise ( ( resolve , reject ) => {
5252 Papa . parse ( file , {
5353 header : true ,
5454 dynamicTyping : true ,
5555 skipEmptyLines : 'greedy' ,
5656 ...options ,
57+ error : ( error , file ) => reject ( error , file ) ,
5758 download : true ,
5859 complete : results => {
5960 const df = new DataFrame ( results . data , frameConfig ) ;
@@ -81,7 +82,7 @@ const $readCSV = async (file: any, options?: CsvInputOptionsBrowser): Promise<Da
8182const $streamCSV = async ( file : string , callback : ( df : DataFrame ) => void , options : CsvInputOptionsBrowser , ) : Promise < null > => {
8283 const frameConfig = options ?. frameConfig || { }
8384
84- return new Promise ( resolve => {
85+ return new Promise ( ( resolve , reject ) => {
8586 let count = 0
8687 Papa . parse ( file , {
8788 ...options ,
@@ -92,7 +93,8 @@ const $streamCSV = async (file: string, callback: (df: DataFrame) => void, optio
9293 const df = new DataFrame ( [ results . data ] , { ...frameConfig , index : [ count ++ ] } ) ;
9394 callback ( df ) ;
9495 } ,
95- complete : ( ) => resolve ( null )
96+ complete : ( ) => resolve ( null ) ,
97+ error : ( error , file ) => reject ( error , file )
9698 } ) ;
9799 } ) ;
98100} ;
0 commit comments