Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9fa715f

Browse files
authored
Allow user to handle errors
The code doesn't reject the promise when a error occurs so makes it impossible for the user to catch the problem.I'm not sure if this patch will work but this is an issue anyway.
1 parent7638681 commit9fa715f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎src/danfojs-base/io/browser/io.csv.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ import Papa from 'papaparse'
4848
const$readCSV=async(file:any,options?:CsvInputOptionsBrowser):Promise<DataFrame>=>{
4949
constframeConfig=options?.frameConfig||{}
5050

51-
returnnewPromise(resolve=>{
51+
returnnewPromise((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
constdf=newDataFrame(results.data,frameConfig);
@@ -81,7 +82,7 @@ const $readCSV = async (file: any, options?: CsvInputOptionsBrowser): Promise<Da
8182
const$streamCSV=async(file:string,callback:(df:DataFrame)=>void,options:CsvInputOptionsBrowser,):Promise<null>=>{
8283
constframeConfig=options?.frameConfig||{}
8384

84-
returnnewPromise(resolve=>{
85+
returnnewPromise((resolve,reject)=>{
8586
letcount=0
8687
Papa.parse(file,{
8788
...options,
@@ -92,7 +93,8 @@ const $streamCSV = async (file: string, callback: (df: DataFrame) => void, optio
9293
constdf=newDataFrame([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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp