Allow user to handle errors · javascriptdata/danfojs@9fa715f · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit 9fa715f

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 parent 7638681 commit 9fa715f

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
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
8182
const $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

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.