rolldown icon indicating copy to clipboard operation
rolldown copied to clipboard

[Feature Request]: expose error information on JS API error object

Open yyx990803 opened this issue 1 year ago • 4 comments

What problem does this feature solve?

When there is an error from API-based usage, e.g. a missing export:

try {
  const bundle = await rolldown({
    input: '...'
  })
  const generated = await bundle.generate({ format: 'cjs' })
} catch (e) {
  console.log(e) // e doesn't expose anything useful
}

The error message is printed to the console, but the caught error object doesn't contain the same information. e.message is "Build failed" and e.code is "GenericFailure" - which are not really helpful.

What does the proposed API look like?

e.message and e.code should contain more specific information.

yyx990803 avatar Aug 12 '24 07:08 yyx990803

I think this one is solved. Errors returned from rust or caught in Js would be displayed as it is.

--- edited

looks like there are much to be improved

hyf0 avatar Oct 26 '25 07:10 hyf0

looks like there are much to be improved

Would you clarify this?

sapphi-red avatar Nov 05 '25 11:11 sapphi-red

looks like there are much to be improved

Would you clarify this?

I reopen it becuase of reqeust I saw in https://github.com/rolldown/rolldown/issues/2734.

It seemed it was suggesting add more specific fields to the each individual error object.

hyf0 avatar Nov 05 '25 11:11 hyf0

I see. Warnings support id and exporter property (https://github.com/rolldown/rolldown/pull/3711).

I think we can close this issue once we support id, exporter, loc, pos.

related code: https://github.com/rolldown/rolldown/blob/06f24c0bc72d8700fec4563a97aa730510d2023c/crates/rolldown_binding/src/types/error/native_error.rs#L4-L7

sapphi-red avatar Nov 05 '25 11:11 sapphi-red

#7341

sapphi-red avatar Dec 06 '25 05:12 sapphi-red