Skip to content

Commit

Permalink
Changing error messages to not be capitlised
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenldl committed Apr 12, 2024
1 parent ff5c732 commit 9c79135
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
24 changes: 12 additions & 12 deletions timedesc-sexp/of_sexp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,45 @@ let int_of_sexp (x : Sexp.t) =
| Atom s -> (
try int_of_string s
with Failure _ ->
invalid_data (Printf.sprintf "Failed to parse int: %s" s))
invalid_data (Printf.sprintf "failed to parse int: %s" s))
| List _ ->
invalid_data
(Printf.sprintf "Expected atom for int: %s" (Sexp.to_string x))
(Printf.sprintf "expected atom for int: %s" (Sexp.to_string x))

let ints_of_sexp_list (x : Sexp.t) =
match x with
| Atom _ ->
invalid_data
(Printf.sprintf "Expected list for ints: %s" (Sexp.to_string x))
(Printf.sprintf "expected list for ints: %s" (Sexp.to_string x))
| List l -> List.map int_of_sexp l

let span_of_sexp (x : Sexp.t) =
match x with
| Atom _ ->
invalid_data
(Printf.sprintf "Expected list for span: %s" (Sexp.to_string x))
(Printf.sprintf "expected list for span: %s" (Sexp.to_string x))
| List [ s; ns ] ->
let s = int64_of_sexp s in
let ns = int_of_sexp ns in
T.Span.make ~s ~ns ()
| List _ ->
invalid_data
(Printf.sprintf "List too long for span: %s" (Sexp.to_string x))
(Printf.sprintf "list too long for span: %s" (Sexp.to_string x))

let tz_make_of_sexp (x : Sexp.t) =
match x with
| Atom s -> (
match T.Time_zone.make s with
| Some x -> x
| None -> invalid_data (Printf.sprintf "Unrecognized time zone: %s" s))
| None -> invalid_data (Printf.sprintf "unrecognized time zone: %s" s))
| List _ ->
invalid_data
(Printf.sprintf "Expected atom for time zone: %s" (Sexp.to_string x))
(Printf.sprintf "expected atom for time zone: %s" (Sexp.to_string x))

let tz_info_of_sexp (x : Sexp.t) : T.Time_zone_info.t =
match x with
| Atom _ ->
invalid_data (Printf.sprintf "Invalid tz_info: %s" (Sexp.to_string x))
invalid_data (Printf.sprintf "invalid tz_info: %s" (Sexp.to_string x))
| List l -> (
match l with
| [ x ] -> T.Time_zone_info.make_exn ~tz:(tz_make_of_sexp x) ()
Expand All @@ -59,11 +59,11 @@ let tz_info_of_sexp (x : Sexp.t) : T.Time_zone_info.t =
()
| _ ->
invalid_data
(Printf.sprintf "Invalid tz_info: %s" (Sexp.to_string x)))
(Printf.sprintf "invalid tz_info: %s" (Sexp.to_string x)))

let date_of_sexp (x : Sexp.t) =
let invalid_data () =
invalid_data (Printf.sprintf "Invalid date: %s" (Sexp.to_string x))
invalid_data (Printf.sprintf "invalid date: %s" (Sexp.to_string x))
in
match x with
| List [ year; month; day ] -> (
Expand All @@ -77,7 +77,7 @@ let date_of_sexp (x : Sexp.t) =

let time_of_sexp (x : Sexp.t) =
let invalid_data () =
invalid_data (Printf.sprintf "Invalid time: %s" (Sexp.to_string x))
invalid_data (Printf.sprintf "invalid time: %s" (Sexp.to_string x))
in
match x with
| List [ hour; minute; second; ns ] -> (
Expand All @@ -103,7 +103,7 @@ let zoneless_of_sexp (x : Sexp.t) =

let date_time_of_sexp (x : Sexp.t) =
let invalid_data () =
invalid_data (Printf.sprintf "Invalid date time: %s" (Sexp.to_string x))
invalid_data (Printf.sprintf "invalid date time: %s" (Sexp.to_string x))
in
match x with
| List [ date; time; tz; offset_from_utc ] ->
Expand Down
10 changes: 5 additions & 5 deletions timedesc-sexp/of_sexp_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ let int_of_sexp (x : Sexp.t) =
| Atom s -> (
try int_of_string s
with Failure _ ->
invalid_data (Printf.sprintf "Failed to parse int: %s" s))
invalid_data (Printf.sprintf "failed to parse int: %s" s))
| List _ ->
invalid_data
(Printf.sprintf "Expected atom for int: %s" (Sexplib.Sexp.to_string x))
(Printf.sprintf "expected atom for int: %s" (Sexplib.Sexp.to_string x))

let int64_of_sexp (x : Sexp.t) =
match x with
| Atom s -> (
try Int64.of_string s
with Failure _ ->
invalid_data (Printf.sprintf "Failed to parse int64: %s" s))
invalid_data (Printf.sprintf "failed to parse int64: %s" s))
| List _ ->
invalid_data
(Printf.sprintf "Expected atom for int64: %s" (Sexplib.Sexp.to_string x))
(Printf.sprintf "expected atom for int64: %s" (Sexplib.Sexp.to_string x))

let wrap_of_sexp (f : Sexp.t -> 'a) : Sexp.t -> ('a, string) result =
fun x ->
Expand All @@ -34,5 +34,5 @@ let wrap_of_sexp_into_of_sexp_string (f : Sexplib.Sexp.t -> 'a) :
string -> ('a, string) result =
fun s ->
match Sexplib.Sexp.of_string s with
| exception _ -> Error "Failed to parse string into sexp"
| exception _ -> Error "failed to parse string into sexp"
| x -> (wrap_of_sexp f) x

0 comments on commit 9c79135

Please sign in to comment.