Skip to content

Commit 66e6f70

Browse files
committed
fix: clean up bridge error conversion and add debug logging
Remove redundant UnknownError case that duplicated the default branch, add debug logging for unrecognized bridge error types to aid troubleshooting, and document the ServiceError cast behavior.
1 parent 6520276 commit 66e6f70

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

packages/db-client/src/utils/convertBridgeError.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ import {
77
DeadlineExceededError,
88
UnknownError,
99
} from "./CommandError";
10+
import { debug } from "./debug";
1011
import { ServiceError } from "@grpc/grpc-js";
1112

1213
export const convertBridgeError = (error: Error, streamName?: string) => {
1314
const stream = streamName ?? "unknown stream";
15+
16+
// Bridge errors are plain Error objects from the Rust native addon with
17+
// name, message, and metadata (plain object). They lack gRPC-specific
18+
// ServiceError properties (code, details) but CommandErrorBase handles this.
1419
const serviceError = error as ServiceError;
1520

1621
switch (error.name) {
@@ -26,9 +31,12 @@ export const convertBridgeError = (error: Error, streamName?: string) => {
2631
return new UnavailableError(serviceError);
2732
case "DeadlineExceededError":
2833
return new DeadlineExceededError(serviceError);
29-
case "UnknownError":
30-
return new UnknownError(serviceError);
3134
default:
35+
debug.connection(
36+
"Unrecognized bridge error type '%s': %s",
37+
error.name,
38+
error.message
39+
);
3240
return new UnknownError(serviceError);
3341
}
3442
};

0 commit comments

Comments
 (0)