Skip to content
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

parseAsync method Error handling #411

Closed
JonARea opened this issue Aug 15, 2019 · 1 comment · Fixed by #412
Closed

parseAsync method Error handling #411

JonARea opened this issue Aug 15, 2019 · 1 comment · Fixed by #412
Labels

Comments

@JonARea
Copy link

JonARea commented Aug 15, 2019

json2csv v4.5.2
node v10+

I'm running into either an error in documentation or an issue with error handling of the parseAsync method.

I would expect, based on the documentation, for the code below to be caught in the catch block and run the resulting error handling, but the method throws early without the error bubbling out, making it impossible to catch this way

json2csv.parseAsync({}, {fields: [undefined]})
  .then(() => console.log('it works'))
  .catch(err => console.log('an error occurred'))

Wrapping the function in a try / catch block solves the issue

try {
  json2csv.parseAsync({}, {fields: [undefined]})
} catch (err) {
  console.log('there was an error yo')
}

So maybe either the docs should be updated or the behavior changed as desired.

Thanks so much for your work on the tool - it's extremely useful and well done!

@juanjoDiaz juanjoDiaz added the bug label Aug 16, 2019
@juanjoDiaz
Copy link
Collaborator

You are right. It's a bug.
I'll fix it asap.

Thanks for reporting!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants