package jsonxt

  1. Overview
  2. Docs

Source file error_info.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(* contains the line and character span of where the error occured *)

type t = {
  line : int
; start_char : int
; end_char : int
; msg : string
}

exception Json_error_info of t

let create_from_lexbuf lexbuf emsg =
  let (eline, schar, echar) = Lexxer_utils.error_pos lexbuf in
  { line = eline; start_char = schar; end_char = echar; msg = emsg }

let to_string info =
  let loc = Printf.sprintf "line %d chars %d-%d" info.line info.start_char info.end_char in
  info.msg ^ " at " ^ loc