GHHG10's picture
download
raw
902 Bytes
import { Effect } from "effect"
import { HttpApiMiddleware } from "effect/unstable/httpapi"
import { InvalidRequestError } from "../errors"
const REASON_LIMIT = 1024
function truncateReason(reason: string) {
if (reason.length <= REASON_LIMIT) return reason
return reason.slice(0, REASON_LIMIT) + `... (${reason.length - REASON_LIMIT} more chars)`
}
export class SchemaErrorMiddleware extends HttpApiMiddleware.Service<SchemaErrorMiddleware>()(
"@opencode/HttpApiSchemaError",
{ error: InvalidRequestError },
) {}
export const schemaErrorLayer = HttpApiMiddleware.layerSchemaErrorTransform(SchemaErrorMiddleware, (error) => {
const reason = truncateReason(error.cause.message)
return Effect.logWarning("schema rejection").pipe(
Effect.annotateLogs({ kind: error.kind, reason }),
Effect.andThen(Effect.fail(new InvalidRequestError({ message: reason, kind: error.kind }))),
)
})

Xet Storage Details

Size:
902 Bytes
·
Xet hash:
f71af7f8fd615a5dbc06c6b4e33dc9f0dbfdd0e6e7f5dba855e1a52f1701057d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.