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

cli-lib's extract function ignores throws setting for errors in processFile #4404

Closed
TNick opened this issue Apr 28, 2024 · 0 comments
Closed

Comments

@TNick
Copy link

TNick commented Apr 28, 2024

https://github.com/formatjs/formatjs/blob/c063f7bc4530af7ec6c5b68000887a3f55948f6e/packages/cli-lib/src/extract.ts#L200C18

try {
  const source = await readFile(fn, 'utf8')
  return processFile(source, fn, opts)
} catch (e) {
  if (throws) {
    throw e
  } else {
    warn(String(e))
  }
}

In this code exceptions thrown in processFile will not be caught because processFile is an async function.

Is this the intention or is it a bug?

try {
  const source = await readFile(fn, 'utf8')
  return Promise.resolve(await processFile(source, fn, opts));
} catch (e) {
  if (throws) {
    throw e
  } else {
    warn(String(e))
  }
}
@longlho longlho closed this as completed in 2195fc0 May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant