Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/durabletask-js-azuremanaged/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ abstract class DurableTaskAzureManagedOptionsBase {
authority = `${authority}:${url.port}`;
}
return authority;
} catch {
throw new Error(`Invalid endpoint URL: ${endpoint}`);
} catch (e) {
throw new Error(`Invalid endpoint URL: ${endpoint}`, { cause: e });
}
}

Expand Down
17 changes: 17 additions & 0 deletions packages/durabletask-js-azuremanaged/test/unit/options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ describe("Options", () => {

expect(() => options.getHostAddress()).toThrow("Invalid endpoint URL:");
});

it("should preserve the original error as cause when URL parsing fails", () => {
const options = new DurableTaskAzureManagedClientOptions().setEndpointAddress("invalid:url");

try {
options.getHostAddress();
fail("Expected getHostAddress to throw");
} catch (e: unknown) {
expect(e).toBeInstanceOf(Error);
const error = e as Error;
expect(error.message).toContain("Invalid endpoint URL:");
expect(error.cause).toBeDefined();
// The cause should be the original URL parsing error
expect((error.cause as Error).message).toBeDefined();
expect((error.cause as Error).message.length).toBeGreaterThan(0);
}
});
});

describe("createChannelCredentials", () => {
Expand Down
Loading