Skip to content

Commit

Permalink
Throw InternalClientError instead of string
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttrinh committed Jan 28, 2025
1 parent 133c643 commit 62a2199
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/driver/src/codecs/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ import { Codec } from "./ifaces";
import type { Codecs } from "./codecs";
import type { WriteBuffer } from "../primitives/buffer";
import { ReadBuffer } from "../primitives/buffer";
import { InvalidArgumentError, ProtocolError } from "../errors";
import {
InternalClientError,
InvalidArgumentError,
ProtocolError,
} from "../errors";
import type { CodecContext } from "./context";

const SQLRowArrayCodec: Codecs.SQLRowCodec = {
fromDatabase(values: any[], _desc: { names: string[] }): any[] {
return values;
},
toDatabase() {
throw "cannot encode SQL record as a query argument";
throw new InternalClientError(
"cannot encode SQL record as a query argument",
);
},
};

Expand All @@ -38,7 +44,9 @@ const SQLRowObjectCodec: Codecs.SQLRowCodec = {
return Object.fromEntries(names.map((key, index) => [key, values[index]]));
},
toDatabase() {
throw "cannot encode SQL record as a query argument";
throw new InternalClientError(
"cannot encode SQL record as a query argument",
);
},
};

Expand Down

0 comments on commit 62a2199

Please sign in to comment.