Something went wrong. Try again.
SQL frontend over the catalog engine
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455(*--------------------------------------------------------------------------- Copyright (c) 2026 Thomas Gazagnaire. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*)
module Error = Catalog.Error
type t = Error.t
(* sqlite3_mprintf's %Q: the text in single quotes, each quote doubled *)let quoted s = let b = Buffer.create (String.length s + 2) in Buffer.add_char b '\''; String.iter (fun c -> if c = '\'' then Buffer.add_string b "''" else Buffer.add_char b c) s; Buffer.add_char b '\''; Buffer.contents b
let malformed = Error.Runtime "malformed JSON"let fail_malformed () = Error.fail malformedlet too_deep = Error.Runtime "JSON nested too deep"let fail_too_deep () = Error.fail too_deep
type path = Bad_path | Not_array_element | Path_too_deep | Malformed
let path p text = match p with | Not_array_element -> Error.Runtime ("not an array element: " ^ quoted text) | Malformed -> malformed | Path_too_deep -> Error.Runtime "JSON path too deep" | Bad_path -> Error.Runtime ("bad JSON path: " ^ quoted text)
let fail_path p text = Error.fail (path p text)
let sort ~exp ~fnd = Fmt.kstr (fun s -> Error.Runtime s) "JSONB: expected %s, found %s" exp (match fnd with Some s -> Jsonb_sort.to_string s | None -> "reserved")
let fail_sort ~exp ~fnd = Error.fail (sort ~exp ~fnd)
let no_encoder kind = Fmt.kstr (fun s -> Error.Runtime s) "JSONB: no encoder for %s" kind
let fail_no_encoder kind = Error.fail (no_encoder kind)
let no_decoder kind = Fmt.kstr (fun s -> Error.Runtime s) "JSONB: no decoder for %s" kind
let fail_no_decoder kind = Error.fail (no_decoder kind)let pp = Error.pp