Skip to content

Conversation

@KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented Jun 19, 2025

Refactor: Replace deprecated errorAndThrow with errorWithException

This PR updates the codebase to replace all usages of the deprecated errorAndThrow method with the recommended errorWithException method. Error messages are now wrapped in a new Error object for improved error handling and stack traces.

Details:

  • Updated driver/lib/sessions/session.ts and driver/lib/sessions/observatory.ts to use this.log.errorWithException(new Error(...)) instead of this.log.errorAndThrow(...).
  • No functional changes; this is a refactor to align with current logging and error-handling best practices.

Motivation:

  • Removes usage of deprecated methods.
  • Ensures better error stack traces and future compatibility.

@KazuCocoa KazuCocoa requested a review from Copilot June 19, 2025 05:00
@KazuCocoa KazuCocoa changed the title refactor: replace deprecated errorAndThrow with errorWithException in… refactor: replace deprecated errorAndThrow with errorWithException in session and observatory modules Jun 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors error handling in the session and observatory modules by replacing deprecated errorAndThrow calls with errorWithException.

  • Replaces errorAndThrow with errorWithException in session.ts for missing or unsupported platformName cases.
  • Applies similar error handling updates in observatory.ts for handling exceptions during socket connection.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
driver/lib/sessions/session.ts Updated error handling by wrapping messages in new Error and replacing deprecated functions.
driver/lib/sessions/observatory.ts Updated error handling to use errorWithException with error object wrapping.
Comments suppressed due to low confidence (1)

driver/lib/sessions/observatory.ts:68

  • [nitpick] Consider passing the original error object (or including it as a property) to retain error context, which could be more helpful for debugging compared to a JSON string.
          this.log.errorWithException(new Error(JSON.stringify(e)));

@KazuCocoa KazuCocoa merged commit 924b9f6 into main Jun 19, 2025
10 of 12 checks passed
@KazuCocoa KazuCocoa deleted the fix/replace-errorAndThrow-with-errorWithException branch June 19, 2025 05:12
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

Successfully merging this pull request may close these issues.

2 participants