fix: Preserve original URL parsing error cause in getHostAddress()#194
fix: Preserve original URL parsing error cause in getHostAddress()#194YunchuWang wants to merge 1 commit intomainfrom
Conversation
The getHostAddress() method in DurableTaskAzureManagedClientOptions drops the original URL parsing error when re-throwing, making it difficult to debug why a specific endpoint URL is invalid. This change preserves the original error as the cause property of the new Error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves debuggability of Azure Managed SDK endpoint configuration by preserving the original URL parsing error when getHostAddress() rejects an invalid endpoint, aligning with existing error-wrapping patterns in the repo.
Changes:
- Preserve the original URL parsing exception by rethrowing with
new Error(..., { cause: e })ingetHostAddress(). - Add a unit test asserting that the thrown error includes a defined
cause.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/durabletask-js-azuremanaged/src/options.ts |
Wrap URL parsing failures with { cause } so the original parsing error is retained. |
packages/durabletask-js-azuremanaged/test/unit/options.spec.ts |
Adds a test to validate that getHostAddress() preserves the underlying parsing error as cause. |
|
|
||
| try { | ||
| options.getHostAddress(); | ||
| fail("Expected getHostAddress to throw"); |
There was a problem hiding this comment.
The test calls fail("Expected getHostAddress to throw"), but this repo's Jest setup uses the default jest-circus runner (no jest-jasmine2), where fail is not a guaranteed global and can cause a ReferenceError, failing the suite. Prefer throwing an Error in that branch (or structure the test to capture the thrown error without relying on fail).
| fail("Expected getHostAddress to throw"); | |
| throw new Error("Expected getHostAddress to throw"); |
Fixes #191
Problem
getHostAddress() in DurableTaskAzureManagedClientOptions catches URL parsing errors and re-throws a new Error with a descriptive message, but drops the original error. This makes it difficult to diagnose why a specific endpoint URL is invalid.
Changes