You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Comlink] Throw the original error in the error handler (#2407)
## Motivation for the change, related issues
The [new Comlink error
handler](#2357)
rewired the logic around passing errors from web workers to the
Playground web app. Specifically, it enriched the error with additional
stack trace before rethrowing it:
```js
throw new Error('Comlink method call failed', {
cause: originalError
});
```
Unfortunately, this also put the original error at the bottom of the
`error.cause` chain, making error handling confusing for the API
consumers.
This PR ensures the thrown error the original one. This way a simple
`try {} catch(e) {}` is enough to log the error details without having
to reason about `e.cause.cause` etc. The additional stack trace
information is now attached at the bottom of the cause chain for when
the developer needs to inspect it.
## Testing Instructions (or ideally a Blueprint)
Run Playground with this Blueprint and confirm the top-level error
message speaks about PHP failure. Specifically, it should not say
"Comlink method call failed":
```json
{
"steps": [
{
"step": "mkdir",
"path": "/wordpress/wp-content/mu-plugins"
},
{
"step": "writeFile",
"path": "/wordpress/wp-content/mu-plugins/test.php",
"data": "<?php undefined_function();"
}
]
}
```
0 commit comments