Skip to content

Commit

Permalink
fix: implement better short_code
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Sep 5, 2024
1 parent de13059 commit a97de2d
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/Reporter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,33 @@ module Message =
struct
(** Type of error codes. See the asai documentation. *)
type t =

(* Errors from the system environment *)

| SystemError (** Generic system errors. *)
| MissingEnvironmentVariables (** Missing HOME or XDG_* environment variables. *)
| FileError (** File paths are valid, but the files do not exist or file permissions are missing. *)
| IllFormedFilePath (** File paths are ill-formed (independent of the file system state). *)
| WebError (** All the network-related errors. *)
| InvalidOCamlPackage (** Invalid OCaml package. *)

(* Errors from parser *)

| IllFormedJSON (** Low level JSON parsing errors. *)

(* Errors about anchors *)

| AnchorNotFound (** Could not find the anchor at the expected library location. *)
| HijackingAnchor (** Having an anchor on the path to the expected anchor. *)
| IllFormedAnchor (** The anchor itself is ill-formed. *)

(* Errors about resolving *)

| InvalidRouter (** The routing table itself is broken. *)
| LibraryNotFound (** The routing table is okay, but the library cannot be found. *)
| LibraryConflict (** Conflicting libraries are being loaded. *)
| UnitNotFound (** Libraries are loaded, but the unit is not found. *)
| IllFormedUnitPath (** The unit path is ill-formed. *)

| InvalidOCamlPackage (** Invalid OCaml package. *)

(** Default severity of error codes. See the asai documentation. *)
let default_severity : t -> Asai.Diagnostic.severity =
Expand All @@ -30,7 +38,25 @@ struct

(** String representation of error codes. See the asai documentation. *)
let short_code : t -> string =
function _ -> "E0001" (** XXX assign actual code *)
function
| SystemError -> "E0001"
| MissingEnvironmentVariables -> "E0002"
| IllFormedFilePath -> "E0003"
| FileError -> "E0004"
| WebError -> "E0005"
| InvalidOCamlPackage -> "E0006"

| IllFormedJSON -> "E0101"

| AnchorNotFound -> "E0201"
| HijackingAnchor -> "E0202"
| IllFormedAnchor -> "E0203"

| InvalidRouter -> "E0301"
| LibraryNotFound -> "E0302"
| LibraryConflict -> "E0303"
| IllFormedUnitPath -> "E0304"
| UnitNotFound -> "E0305"
end

include Asai.Reporter.Make(Message)

0 comments on commit a97de2d

Please sign in to comment.