(** Error meant for humans *)

(** User errors are errors that users need to fix themselves in order to make
    progress. Since these errors are read by users, they should be simple to
    understand for people who are not familiar with the dune codebase. *)
exception E of User_message.t

(** Raise a user error. The arguments are interpreted in the same way as
    [User_message.make]. The first paragraph is prefixed with "Error:". *)
val raise
  :  ?has_embedded_location:bool
  -> ?needs_stack_trace:bool
  -> ?loc:Loc0.t
  -> ?hints:User_message.Style.t Pp.t list
  -> ?compound:User_message.Compound.t list
  -> ?promotion:User_message.Diff_annot.t
  -> User_message.Style.t Pp.t list
  -> _

(** Create a user error. *)
val make
  :  ?has_embedded_location:bool
  -> ?needs_stack_trace:bool
  -> ?loc:Loc0.t
  -> ?hints:User_message.Style.t Pp.t list
  -> ?compound:User_message.Compound.t list
  -> ?promotion:User_message.Diff_annot.t
  -> User_message.Style.t Pp.t list
  -> User_message.t

(** The "Error:" prefix *)
val prefix : User_message.Style.t Pp.t

(** Helper to raise a user error from a result type.
    - [ok_exn (Ok x)] is [x]
    - [ok_exn (Error msg)] is [Stdlib.raise (E msg)] *)
val ok_exn : ('a, User_message.t) result -> 'a

val reason : User_message.Style.t Pp.t -> User_message.Style.t Pp.t
