MCPcopy Create free account
hub / github.com/Effect-TS/effect / failUnregistered

Function failUnregistered

packages/sql/pg/src/PgTypes.ts:271–287  ·  view source on GitHub ↗
(reason: string, oid: number, column: Column | undefined, index: number)

Source from the content-addressed store, hash-verified

269}
270
271const failUnregistered = (reason: string, oid: number, column: Column | undefined, index: number): never => {
272 let subject: string
273 if (column === undefined) {
274 subject = `a value of type OID ${oid}`
275 } else {
276 const name = column.name === undefined ? `${index}` : JSON.stringify(column.name)
277 const table = column.tableOid === undefined || column.tableOid === 0
278 ? ""
279 : `, table OID ${column.tableOid}, attribute number ${column.columnAttributeNumber}`
280 subject = `column ${name} (type OID ${oid}${table})`
281 }
282 return fail(
283 `Cannot decode ${subject}: no codec is registered for the type, so it is read as UTF-8 text, ` +
284 `but the value ${reason}. Register a codec with PgTypes.makeRegistry().register and pass the registry ` +
285 `as the client's types option, or cast the value to text in the query.`
286 )
287}
288
289const requireSize = (size: number, expected: number, name: string): void => {
290 if (size !== expected) {

Callers 1

decodeUnregisteredFunction · 0.85

Calls 1

failFunction · 0.70

Tested by

no test coverage detected