(*--------------------------------------------------------------------------- Copyright (c) 2025 Thomas Gazagnaire. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** Bottler error model and internal log source. Every fallible operation of the library returns a [string] error, built from a structured {!t} so that each error site names what went wrong. Errors from YAML, JSON, Scaleway, [ocaml-tar] and [brew] subprocesses are converted here and never reach the public API in their own shape. *) module Log : Logs.LOG (** Shared logger, source name [bottler]. *) type config_section = { name : string; (** the section as it is written in the file: ["build"] *) needs : string; (** what bottler does with the section, in one sentence *) example : string list; (** the lines the section reads as *) } (** The type for a top-level section of [homebrew.yml] that a refusal tells its reader to write. {!Config} owns the sentences, since it owns the codec they describe; this module renders them. *) type t = | Tool_not_found of string (** External CLI tool missing from [$PATH]; carries the tool name. *) | Config_parse of string (** [homebrew.yml] failed to parse; carries the underlying parser message. *) | Config_absent of { file : string; dir : string } (** No config where the command line said to look. Bottler bottles the packages that one file declares and has no default for it, so it refuses rather than release nothing. *) | Config_unreadable of { file : string; reason : string } (** The config is there and could not be read; carries what the operating system said. *) | Config_no_section of { file : string; sections : config_section list } (** The config carries none of these top-level sections. *) | Config_no_key of { file : string; section : config_section; keys : string list; } (** A top-level section is there and carries none of these keys. *) | Scaleway_profile of string (** Scaleway profile could not be loaded; carries the underlying message. *) | Tar_unix of Unix.error (** [Unix.error] surfaced by [ocaml-tar] during archive I/O. *) | Tar_fatal of Tar.error (** Fatal structural error from [ocaml-tar]. *) | Brew_failed of { args : string; msg : string } (** [brew ] subprocess exited non-zero. *) | No_bottle of string (** A package build did not produce an installable bottle. *) | No_formula of string (** A tap-level operation (e.g. [bottler remove]) targeted a formula that isn't present in [Formula/]. *) | Upload_unreachable of { url : string; status : int } (** [put_object_file] returned success but a public [HEAD] against the object's URL did not return [200], so the formula about to be pushed would reference a bottle brew cannot download. *) | Bottle_not_served of { name : string; url : string } (** The store serves nothing at the URL a formula's bottle block would point at: the bottle was never uploaded, or not under that key. *) | Bottle_digest_mismatch of { name : string; url : string; served : string } (** The bytes the store serves hash to [served], not to the digest the formula about to be written carries. *) | Unknown_revision of { version : string; revision : string } (** The commit a version names is not in this repository, so the formula's source build would pin a revision nobody can fetch. *) | Build_dir_held of string (** A dune instance already holds the build directory the release build would use. Dune forwards a build request to that instance rather than running it, and the hand-off drops the client's command line and its environment, so the release would carry the dev profile. *) | Target_not_built of { name : string; path : string } (** The release build reported success and the executable a package names is not in the build directory, so bottling would archive an earlier build or drop the package from the release. *) | Formula_unreadable of { name : string; path : string } (** A formula the tap already publishes carries no readable [desc], [version] and [homepage], the three fields a retirement carries over from what was published under that name. *) | Verify_unanswered of { name : string; url : string; reason : string; verified : string list; left : string list; } (** Reading the bottle of package [name] back from [url] failed in transport twice, for [reason]; [verified] are the packages whose served digest was checked before it and [left] the ones not checked, [name] first. *) | Macos_too_new of { name : string; path : string; needs : int * int; target : string; } (** The executable [path] of package [name] records [needs] as its minimum macOS, later than the macOS [target] its bottle is labelled for. *) | Macos_weak_imports of { name : string; path : string; symbols : string list; switch : string; left_out : string list; target : string; } (** The executable [path] of package [name], built under opam switch [switch], imports [symbols] weakly: functions later than macOS [target], [NULL] there. The switch's setenv tells configure to leave out the functions [left_out]. *) | Macos_objects_too_new of { objects : (string * string) list; target : string; } (** A macOS release link took [objects], each a file and the later macOS it is built for, where the bottle targets macOS [target]; ld only warns, so the release link makes its warnings fatal. *) | Switch_too_new of { switch : string; needs : int * int; archives : string list; packages : string list; target : string; } (** The [archives] of opam switch [switch] are built for macOS [needs], later than [target], so whatever links them needs it too, after [packages] were rebuilt with the target set; no package owns them when [packages] is empty. *) | Platform_unbuildable of { platform : string; host : string; why : string } (** [build.platforms] names [platform], which this [host] cannot build, for the reason [why]. *) | Own_workspace of { root : string; file : string } (** The tree at [root] has a [dune-workspace] of its own and no [file] declaring its release context, so the workspace bottler would write for the release would replace the tree's. *) | No_image (** A [static] Linux platform builds in a container of [build.image], which the manifest does not name. *) | Worker_dirty of { worker : string; changes : string list } (** A Linux platform would build on [worker], which builds a commit, while the tree has the uncommitted [changes]. *) | Bottle_digest of { name : string; want : string; got : string } (** The file [name] the container built has the SHA-256 [got] on this host, where its manifest names [want]; [got] is empty when the file did not arrive. *) | Stage_raised of string (** A release step raised rather than returning an error; carries the exception as {!Printexc.to_string} prints it. *) val pp : t Fmt.t (** [pp] formats an error for the person who ran the command: the situation, the facts behind it, and what to do about it. A refusal that has lines to quote runs to several of them, and indents every quoted line by two spaces so the block stands apart from the sentences around it. *) val err : t -> ('a, string) result (** [err e] is [Error] with [e] formatted by {!pp}. *)