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 e5d7b6c commit 6f40974
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 43 deletions.
50 changes: 25 additions & 25 deletions timere/of_sexp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ let month_of_sexp (x : Sexp.t) =
| Sexp.Atom s -> (
match Time.month_of_abbr_string s with
| Some x -> x
| None -> invalid_data (Printf.sprintf "Failed to parse month: %s" s))
| None -> invalid_data (Printf.sprintf "failed to parse month: %s" s))
| List _ ->
invalid_data
(Printf.sprintf "Expected atom for month: %s" (Sexp.to_string x))
(Printf.sprintf "expected atom for month: %s" (Sexp.to_string x))

let weekday_of_sexp (x : Sexp.t) =
match x with
| Sexp.Atom s -> (
match Time.weekday_of_abbr_string s with
| Some x -> x
| None -> invalid_data (Printf.sprintf "Failed to parse weekday: %s" s))
| None -> invalid_data (Printf.sprintf "failed to parse weekday: %s" s))
| List _ ->
invalid_data
(Printf.sprintf "Expected atom for weekday: %s" (Sexp.to_string x))
(Printf.sprintf "expected atom for weekday: %s" (Sexp.to_string x))

let int_of_sexp (x : Sexp.t) =
match x with
| 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 sexp =
Expand All @@ -48,10 +48,10 @@ let tz_make_of_sexp (x : Sexp.t) =
| Atom s -> (
match Timedesc.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 =
match Timedesc_sexp.Time_zone_info.of_sexp x with
Expand All @@ -70,13 +70,13 @@ let range_of_sexp ~(f : Sexp.t -> 'a) (x : Sexp.t) =
match x with
| List [ Atom "range_inc"; x; y ] -> `Range_inc (f x, f y)
| List [ Atom "range_exc"; x; y ] -> `Range_exc (f x, f y)
| _ -> invalid_data (Printf.sprintf "Invalid range: %s" (Sexp.to_string x))
| _ -> invalid_data (Printf.sprintf "invalid range: %s" (Sexp.to_string x))

let iso_week_pattern_of_sexp (x : Sexp.t) =
match x with
| Atom _ ->
invalid_data
(Printf.sprintf "Expected list for ISO week pattern: %s" (Sexp.to_string x))
(Printf.sprintf "expected list for ISO week pattern: %s" (Sexp.to_string x))
| List l -> (
match l with
| [ Atom "iso_week_pattern"; List years; List weeks ]-> (
Expand All @@ -86,14 +86,14 @@ let iso_week_pattern_of_sexp (x : Sexp.t) =
)
| _ ->
invalid_data
(Printf.sprintf "Invalid pattern: %s" (Sexp.to_string x))
(Printf.sprintf "invalid pattern: %s" (Sexp.to_string x))
)

let pattern_of_sexp (x : Sexp.t) =
match x with
| Sexp.Atom _ ->
invalid_data
(Printf.sprintf "Expected list for pattern: %s" (Sexp.to_string x))
(Printf.sprintf "expected list for pattern: %s" (Sexp.to_string x))
| Sexp.List l -> (
match l with
| Atom "pattern" :: l -> (
Expand Down Expand Up @@ -149,7 +149,7 @@ let pattern_of_sexp (x : Sexp.t) =
`Range_inc (int_of_sexp x, int_of_sexp y)
| _ ->
invalid_data
(Printf.sprintf "Invalid pattern: %s"
(Printf.sprintf "invalid pattern: %s"
(Sexp.to_string x)))
ns,
l )
Expand All @@ -161,10 +161,10 @@ let pattern_of_sexp (x : Sexp.t) =
~seconds ~ns_ranges ()
| _ ->
invalid_data
(Printf.sprintf "Invalid pattern: %s" (Sexp.to_string x)))
(Printf.sprintf "invalid pattern: %s" (Sexp.to_string x)))
| _ ->
invalid_data
(Printf.sprintf "Invalid pattern: %s" (Sexp.to_string x)))
(Printf.sprintf "invalid pattern: %s" (Sexp.to_string x)))

let points_of_sexp (x : Sexp.t) : Points.t =
let open Points in
Expand Down Expand Up @@ -228,11 +228,11 @@ let points_of_sexp (x : Sexp.t) : Points.t =
ns = int_of_sexp ns;
}
| _ ->
invalid_data (Printf.sprintf "Invalid points: %s" (Sexp.to_string x))
invalid_data (Printf.sprintf "invalid points: %s" (Sexp.to_string x))
in
match x with
| Atom _ ->
invalid_data (Printf.sprintf "Invalid points: %s" (Sexp.to_string x))
invalid_data (Printf.sprintf "invalid points: %s" (Sexp.to_string x))
| List l -> (
match l with
| [ Atom "points"; List (Atom "pick" :: pick) ] ->
Expand All @@ -244,7 +244,7 @@ let points_of_sexp (x : Sexp.t) : Points.t =
}
| _ ->
invalid_data
(Printf.sprintf "Invalid points: %s" (Sexp.to_string x)))
(Printf.sprintf "invalid points: %s" (Sexp.to_string x)))

let of_sexp (x : Sexp.t) =
let open Time in
Expand All @@ -261,7 +261,7 @@ let of_sexp (x : Sexp.t) =
| Sexp.List [ x; y ] -> (timestamp_of_sexp x, timestamp_of_sexp y)
| _ ->
invalid_data
(Printf.sprintf "Expected list for interval: %s"
(Printf.sprintf "expected list for interval: %s"
(Sexp.to_string x)))
|> sorted_intervals ~skip_invalid:false
| Atom "iso_week_pattern" :: _ -> iso_week_pattern_of_sexp x
Expand All @@ -285,18 +285,18 @@ let of_sexp (x : Sexp.t) =
| "whole_exc" -> (Some `Exc, `Whole)
| "fst" -> (None, `Fst)
| "snd" -> (None, `Snd)
| _ -> invalid_data (Printf.sprintf "Invalid mode: %s" mode)
| _ -> invalid_data (Printf.sprintf "invalid mode: %s" mode)
in
let bound = span_of_sexp bound in
pattern_intervals ?inc_exc ~bound mode (points_of_sexp start)
(points_of_sexp end_)
| [ Atom "unchunk"; x ] -> aux_chunked CCFun.id x
| _ ->
invalid_data
(Printf.sprintf "Invalid timere data: %s" (Sexp.to_string x)))
(Printf.sprintf "invalid timere data: %s" (Sexp.to_string x)))
| Atom _ ->
invalid_data
(Printf.sprintf "Expected list for timere data: %s"
(Printf.sprintf "expected list for timere data: %s"
(Sexp.to_string x))
and aux_chunked f (x : Sexp.t) : Time_ast.t =
let open Infix in
Expand Down Expand Up @@ -350,10 +350,10 @@ let of_sexp (x : Sexp.t) =
chunked
| _ ->
invalid_data
(Printf.sprintf "Invalid timere data: %s" (Sexp.to_string x)))
(Printf.sprintf "invalid timere data: %s" (Sexp.to_string x)))
| Atom _ ->
invalid_data
(Printf.sprintf "Expected list for timere data: %s"
(Printf.sprintf "expected list for timere data: %s"
(Sexp.to_string x))
in
aux x
Expand Down
6 changes: 3 additions & 3 deletions timere/pattern_resolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ module Search_param = struct
in
let start_dt =
CCOption.get_exn_or
"Expected successful date time construction from timestamp"
"expected successful date time construction from timestamp"
@@ Timedesc.of_timestamp ~tz_of_date_time start
in
let end_inc_dt =
CCOption.get_exn_or
"Expected successful date time construction from timestamp"
"expected successful date time construction from timestamp"
@@ Timedesc.of_timestamp ~tz_of_date_time (Timedesc.Span.pred end_exc)
in
{
Expand All @@ -104,7 +104,7 @@ module Search_param = struct
}
end

let failwith_unexpected_case (_ : 'a) = failwith "Unexpected case"
let failwith_unexpected_case (_ : 'a) = failwith "unexpected case"

module Matching_ns = struct
let get_cur_branch_search_start cur_branch = Branch.set_to_first_ns cur_branch
Expand Down
10 changes: 5 additions & 5 deletions timere/points.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,22 @@ let make ?tz ?offset_from_utc ?year ?month ?day ?weekday ?hour ?minute ?second
if not year_is_fine then
Error
(`Invalid_year
(CCOption.get_exn_or "Expected year to be Some _" year))
(CCOption.get_exn_or "expected year to be Some _" year))
else if not month_day_is_fine then
Error
(`Invalid_day (CCOption.get_exn_or "Expected day to be Some _" day))
(`Invalid_day (CCOption.get_exn_or "expected day to be Some _" day))
else if not hour_is_fine then
Error
(`Invalid_hour
(CCOption.get_exn_or "Expected hour to be Some _" hour))
(CCOption.get_exn_or "expected hour to be Some _" hour))
else if not minute_is_fine then
Error
(`Invalid_minute
(CCOption.get_exn_or "Expected minute to be Some _" minute))
(CCOption.get_exn_or "expected minute to be Some _" minute))
else if not second_is_fine then
Error
(`Invalid_second
(CCOption.get_exn_or "Expected second to be Some _" second))
(CCOption.get_exn_or "expected second to be Some _" second))
else
let default_month =
match lean_toward with `Earlier -> 1 | `Later -> 12
Expand Down
18 changes: 9 additions & 9 deletions timere/resolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let deduce_child_result_space_bound_from_parent ~(parent : t) : result_space =
match parent with
| All | Empty | Intervals _ | ISO_week_pattern _
| Pattern _ | Pattern_intervals _ ->
failwith "Unexpected case"
failwith "unexpected case"
| Unary_op (_, op, _) -> (
match op with
| Shift n ->
Expand Down Expand Up @@ -309,14 +309,14 @@ let do_chunk_at_year_boundary tz (s : Time.Interval'.t Seq.t) =
| Seq.Nil -> Seq.empty
| Seq.Cons ((t1, t2), rest) ->
let dt1 =
CCOption.get_exn_or "Expected successful date time construction"
CCOption.get_exn_or "expected successful date time construction"
@@ Timedesc.of_timestamp ~tz_of_date_time:tz t1
in
let dt2 =
t2
|> Timedesc.Span.pred
|> Timedesc.of_timestamp ~tz_of_date_time:tz
|> CCOption.get_exn_or "Expected successful date time construction"
|> CCOption.get_exn_or "expected successful date time construction"
in
let dt1_year = Timedesc.year dt1 in
if dt1_year = Timedesc.year dt2 then fun () ->
Expand All @@ -342,15 +342,15 @@ let do_chunk_at_month_boundary tz (s : Time.Interval'.t Seq.t) =
| Seq.Nil -> Seq.empty
| Seq.Cons ((t1, t2), rest) ->
let dt1 =
CCOption.get_exn_or "Expected successful date time construction"
CCOption.get_exn_or "expected successful date time construction"
@@ Timedesc.of_timestamp ~tz_of_date_time:tz t1
in
let dt1_year = Timedesc.year dt1 in
let dt2 =
t2
|> Timedesc.Span.pred
|> Timedesc.of_timestamp ~tz_of_date_time:tz
|> CCOption.get_exn_or "Expected successful date time construction"
|> CCOption.get_exn_or "expected successful date time construction"
in
if
dt1_year = Timedesc.year dt2
Expand Down Expand Up @@ -575,7 +575,7 @@ and skip_points_in_p1 ~last_start2 ~(rest1 : timestamp Seq.t) ~(p1 : Points.t)

and aux_pattern_intervals ~search_space search_using_tz mode bound p1 p2 =
let _, search_space_end_exc =
CCOption.get_exn_or "Expected successful retrieval of last element in list"
CCOption.get_exn_or "expected successful retrieval of last element in list"
@@ Misc_utils.last_element_of_list search_space
in
let rec aux_pattern_intervals' s1 s2 space1 space2 p1 p2 =
Expand Down Expand Up @@ -660,7 +660,7 @@ and aux_inter search_using_tz timeres =
else
let batch_for_sampling =
CCList.map
(CCOption.get_exn_or "Unexpected None in batch_for_sampling")
(CCOption.get_exn_or "unexpected None in batch_for_sampling")
batch_for_sampling
in
match batch_for_sampling with
Expand Down Expand Up @@ -725,8 +725,8 @@ let resolve' ~search_using_tz (time : t) :
try
Ok (time |> optimize_search_space search_using_tz |> aux search_using_tz)
with
| Interval_is_invalid -> Error "Invalid interval"
| Intervals_are_not_sorted -> Error "Intervals are not sorted"
| Interval_is_invalid -> Error "invalid interval"
| Intervals_are_not_sorted -> Error "intervals are not sorted"

let resolve ?(search_using_tz = Timedesc.Time_zone.utc) (time : Time_ast.t) :
(Time.Interval'.t Seq.t, string) result =
Expand Down
2 changes: 1 addition & 1 deletion timere/time.ml
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ module Weekday_ranges = Ranges.Make (struct
let of_int x =
x
|> Timedesc.Utils.weekday_of_tm_int
|> CCOption.get_exn_or "Expected successful construction of weekday"
|> CCOption.get_exn_or "expected successful construction of weekday"
end)

module Month_day_ranges = Ranges.Make (struct
Expand Down

0 comments on commit 6f40974

Please sign in to comment.