diff options
| author | ยท๐๐ด๐๐๐ฉ๐ค | 2025-12-10 13:00:26 +0000 |
|---|---|---|
| committer | ยท๐๐ด๐๐๐ฉ๐ค | 2025-12-10 13:00:26 +0000 |
| commit | 3df27ffb2bd40f3eaeed6dfb08ef3041cc60bfe0 (patch) | |
| tree | 5ce28db0cd6a4f15a7626fb1b9982e13a7b6f086 /lib/error.ml | |
| parent | d3f85acf813d78c6d9972c8f10ff9c3a76bd0f08 (diff) | |
| download | nixtaml-3df27ffb2bd40f3eaeed6dfb08ef3041cc60bfe0.tar nixtaml-3df27ffb2bd40f3eaeed6dfb08ef3041cc60bfe0.tar.gz nixtaml-3df27ffb2bd40f3eaeed6dfb08ef3041cc60bfe0.tar.bz2 nixtaml-3df27ffb2bd40f3eaeed6dfb08ef3041cc60bfe0.tar.lz nixtaml-3df27ffb2bd40f3eaeed6dfb08ef3041cc60bfe0.tar.xz nixtaml-3df27ffb2bd40f3eaeed6dfb08ef3041cc60bfe0.tar.zst nixtaml-3df27ffb2bd40f3eaeed6dfb08ef3041cc60bfe0.zip | |
ocaml onset
Diffstat (limited to 'lib/error.ml')
| -rw-r--r-- | lib/error.ml | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/error.ml b/lib/error.ml new file mode 100644 index 0000000..4255c79 --- /dev/null +++ b/lib/error.ml @@ -0,0 +1,77 @@ +(*โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ +โ SPDX-FileCopyrightText: 2025 toastal <https://toast.al/contact/> โ +โ SPDX-License-Identifier: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception โ +โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ*) +open Name + +type manifest_error = [ + | `Parsing of Util.KDL.Valid.err list + | `Not_set_up + | `File_already_exists +] +[@@deriving show] + +type lockfile_error = [ + | `Parsing of string + | `Serializing of string +] +[@@deriving show] + +type prefetch_method = [ + | `URL + | `Git + | `Darcs + | `Pijul +] +[@@deriving show] + +type prefetch_error = [ + | `Empty_output of prefetch_method + | `Stderr of prefetch_method * string + | `JSON_parsing of prefetch_method * string + | `Darcs_context of string + | `Exception of prefetch_method * string +] +[@@deriving show] + +type input_foreman_error = [ + | `Could_not_add of Name.t + | `Could_not_drop of Name.t + | `Could_not_get of Name.t + | `Could_not_set of Name.t + | `Latest_cmd_empty of Name.t + | `Latest_cmd_fail of Name.t * string + | `Latest_cmd_stderr of Name.t * string + | `Prefetch of Name.t * prefetch_error + | `Pool_exception of string + (* FIXME: string list *) + | `Many_errors of string list +] +[@@deriving show] + +type error = [ + | `Manifest of manifest_error + | `Lockfile of lockfile_error + | `Version_mismatch of string * string + | `Input_foreman of input_foreman_error +] +[@@deriving show] + +let [@inline]tag_manifest (res : ('a, manifest_error) result) = + Result.map_error (fun err -> `Manifest err) res + +let [@inline]tag_lockfile (res : ('a, lockfile_error) result) = + Result.map_error (fun err -> `Lockfile err) res + +let [@inline]tag_input_foreman res = + Result.map_error (fun err -> `Input_foreman err) res + +let pp ppf = function + | `Manifest err -> + Fmt.(pf ppf "%a" pp_manifest_error err) + | `Lockfile err -> + Fmt.(pf ppf "%a" pp_lockfile_error err) + | `Version_mismatch (mnfst, lock) -> + Fmt.pf ppf "Version mismatch: Manifest@@%s & Lockfile@@%s" mnfst lock + | `Input_foreman (`CouldNotAdd name) -> + Fmt.pf ppf "Could not set %a" Name.pp name |
