[fix]: expose error `cause` in `UnderstudyCommandException`
Merged
SE
9mo ago+106+106+012345678901234567890123456789-21-21-01234567890123456789
why
- to make the error more informative & actionable
what changed
- moved
UnderstudyCommandExceptionintosdkErrors.ts - added
causeparam - updated callsites in
actHandlerUtils.tsto include cause
test plan
- added unit tests in
understudy-command-exception.test.ts
Summary by cubic
Expose the original error as the cause in UnderstudyCommandException to preserve stack traces and context during Understudy actions, with type-safe handling for non-Error values. Addresses Linear STG-1310.
- Bug Fixes
- Add cause to UnderstudyCommandException (extends StagehandError).
- Pass original error as cause across handlers; safely compute message/stack for non-Error values.
- Prevent double-wrapping by rethrowing existing UnderstudyCommandException in performUnderstudyMethod.
- Expose UnderstudyCommandException in the public API and add unit tests for name, message, cause, and stack.