[OCaml] Mobile-friendly clone of cgit.
refactor pair the load_error printers as pp/show
pp_load_error and load_error_to_string are the Format printer and its string wrapper, but the names gave no hint they belong together, so the Format-based one looked unused rather than primitive. Rename the wrapper to show_load_error, following the pp_/show_ convention ppx_deriving established. Callers that want composition use "%a" with the printer; callers that want a string use show_.
Changed files
lib/config.ml
@@ -221,6 +221,11 @@
221
221
in
222
222
first_existing (implicit_config_files ())
223
223
224
Added:
(* [pp_load_error] and [show_load_error] follow the convention established by
225
Added:
ppx_deriving: [pp_] is the Format-based printer that composes with "%a", and
226
Added:
[show_] is the string-producing convenience built on it. Naming them as a
227
Added:
pair signals that relationship, which [load_error_to_string] did not. *)
228
Added:
224
229
let pp_load_error formatter = function
225
230
| Not_found file ->
226
231
Format.fprintf formatter "configuration file not found: %s" file
@@ -231,4 +236,4 @@
231
236
| Io_error message ->
232
237
Format.fprintf formatter "could not read configuration: %s" message
233
238
234
Removed:
let load_error_to_string error = Format.asprintf "%a" pp_load_error error
239
Added:
let show_load_error error = Format.asprintf "%a" pp_load_error error
lib/main.ml
@@ -19,7 +19,7 @@
19
19
| Ok config -> config
20
20
| Error error ->
21
21
if Option.is_some git_project_root then Config.default
22
Removed:
else failwith (Config.load_error_to_string error)
22
Added:
else failwith (Config.show_load_error error)
23
23
in
24
24
let config =
25
25
match git_project_root with
test/test_helpers.ml
@@ -44,5 +44,4 @@
44
44
| Unix.WSIGNALED signal | Unix.WSTOPPED signal ->
45
45
Alcotest.failf "git stopped by signal %d" signal
46
46
47
Removed:
let fail_config_error error =
48
Removed:
Alcotest.fail (Ogit.Config.load_error_to_string error)
47
Added:
let fail_config_error error = Alcotest.fail (Ogit.Config.show_load_error error)