Monorepo management for opam overlays
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(monopam): add err_* helpers for E340 compliance

Extract error construction into named helpers at module top:
- import.ml: err_dir_exists
- mono_lock.ml: err_load
- sources_registry.ml: err_invalid, err_load
- verse_registry.ml: rename err to err_other

+28 -10
+5 -2
lib/import.ml
··· 7 7 8 8 module Log = (val Logs.src_log src : Logs.LOG) 9 9 10 + (** {1 Errors} *) 11 + 12 + let err_dir_exists name = Error (Fmt.str "Directory already exists: %s" name) 13 + 10 14 (** {1 Types} *) 11 15 12 16 type source = ··· 134 138 let target_eio = Eio.Path.(fs / Fpath.to_string target) in 135 139 let prefix_path = Fpath.(target / name) in 136 140 (* Check if subtree already exists *) 137 - if dir_exists ~fs prefix_path then 138 - Error (Fmt.str "Directory already exists: %s" name) 141 + if dir_exists ~fs prefix_path then err_dir_exists name 139 142 else begin 140 143 let ref_to_use = 141 144 match ref_ with
+8 -2
lib/mono_lock.ml
··· 18 18 19 19 type t = (string * entry) list 20 20 21 + (** {1 Errors} *) 22 + 23 + let err_load exn = 24 + Error (Fmt.str "Error loading mono.lock: %s" (Printexc.to_string exn)) 25 + 26 + (** {1 Operations} *) 27 + 21 28 let empty = [] 22 29 let find t ~name = List.assoc_opt name t 23 30 let add t ~name entry = (name, entry) :: List.remove_assoc name t ··· 75 82 try 76 83 let content = Eio.Path.load eio_path in 77 84 Ok (of_string content) 78 - with exn -> 79 - Error (Fmt.str "Error loading mono.lock: %s" (Printexc.to_string exn))) 85 + with exn -> err_load exn) 80 86 | _ -> Ok empty 81 87 | exception _ -> Ok empty 82 88
+11 -4
lib/sources_registry.ml
··· 12 12 13 13 type t = { default_url_base : string option; entries : (string * entry) list } 14 14 15 + (** {1 Errors} *) 16 + 17 + let err_invalid msg = Error (Fmt.str "Invalid sources.toml: %s" msg) 18 + 19 + let err_load exn = 20 + Error (Fmt.str "Error loading sources.toml: %s" (Printexc.to_string exn)) 21 + 22 + (** {1 Operations} *) 23 + 15 24 let empty = { default_url_base = None; entries = [] } 16 25 let default_url_base t = t.default_url_base 17 26 let with_default_url_base t base = { t with default_url_base = Some base } ··· 88 97 match Eio.Path.kind ~follow:true eio_path with 89 98 | `Regular_file -> ( 90 99 try Ok (Tomlt_eio.decode_path_exn codec ~fs path_str) with 91 - | Failure msg -> Error (Fmt.str "Invalid sources.toml: %s" msg) 92 - | exn -> 93 - Error 94 - (Fmt.str "Error loading sources.toml: %s" (Printexc.to_string exn))) 100 + | Failure msg -> err_invalid msg 101 + | exn -> err_load exn) 95 102 | _ -> Ok empty (* File doesn't exist, return empty registry *) 96 103 | exception _ -> Ok empty 97 104
+4 -2
lib/verse_registry.ml
··· 96 96 Error (Fmt.str "Registry IO error: %s" (Printexc.to_string exn)) 97 97 98 98 let err_invalid msg = Error (Fmt.str "Invalid registry: %s" msg) 99 - let err exn = Error (Fmt.str "Registry error: %s" (Printexc.to_string exn)) 99 + 100 + let err_other exn = 101 + Error (Fmt.str "Registry error: %s" (Printexc.to_string exn)) 100 102 101 103 let load ~fs path = 102 104 let path_str = Fpath.to_string path in ··· 116 118 | exn -> 117 119 Logs.err (fun m -> 118 120 m "Unexpected registry error: %s" (Printexc.to_string exn)); 119 - err exn 121 + err_other exn 120 122 121 123 let save ~fs path registry = 122 124 let path_str = Fpath.to_string path in