-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data transforms error handling #574
Comments
This does not happen in v6 which was just published as a separate package: https://www.npmjs.com/package/@json2csv/node Although, the API has changed to make the async api more similar than the other. const { pipeline } = require('node:stream/promises');
// ...
try {
pipeline(asyncParser.parse(mockDataStream), process.stdout).catch(err => {
console.log('Something happened');
});
} catch (error) {
console.log('Hello?');
} or using the transform const json2csvTransform = new Transform({ transforms: [dataTransform] }, { objectMode: true });
try {
pipeline(mockDataStream, json2csvTransform, process.stdout).catch(err => {
console.log('Something happened');
});
} catch (error) {
console.log('Hello?');
} I haven't tested the code. It's just a quick guidelines. |
Thank you @juanjoDiaz I didn't know that package existed, is this repo "deprecated" then? |
Yup. I'd consider it deprecated. |
Hi, I'm having some trouble handling errors caused on data transform functions.
json2csv: 5.0.7
Node v16.13.2
When you run this code
You cannot handle the exception, it'll be an unhandledException one.
Only approach that works is to put a try catch inside the data transform function like this.
The text was updated successfully, but these errors were encountered: