[fix]: expose error `cause` in `UnderstudyCommandException`

Merged
SE
9mo ago
+106-21

why

  • to make the error more informative & actionable

what changed

  • moved UnderstudyCommandException into sdkErrors.ts
  • added cause param
  • updated callsites in actHandlerUtils.ts to 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.