Enhance the Augeas.Error exception
[ocaml-augeas.git] / augeas.mli
index 64e8240..a896270 100644 (file)
 type t
   (** Augeas library handle. *)
 
-exception Error of string
-  (** This exception is thrown when the underlying Augeas library
-      returns an error. *)
-
 type flag =
   | AugSaveBackup                      (** Rename original with .augsave *)
   | AugSaveNewFile                     (** Save changes to .augnew *)
@@ -34,6 +30,32 @@ type flag =
   | AugNoLoad
   (** Flags passed to the {!create} function. *)
 
+type error_code =
+  | AugErrInternal             (** Internal error (bug) *)
+  | AugErrPathX                        (** Invalid path expression *)
+  | AugErrNoMatch              (** No match for path expression *)
+  | AugErrMMatch               (** Too many matches for path expression *)
+  | AugErrSyntax               (** Syntax error in lens file *)
+  | AugErrNoLens               (** Lens lookup failed *)
+  | AugErrMXfm                 (** Multiple transforms *)
+  | AugErrNoSpan               (** No span for this node *)
+  | AugErrMvDesc               (** Cannot move node into its descendant *)
+  | AugErrCmdRun               (** Failed to execute command *)
+  | AugErrBadArg               (** Invalid argument in funcion call *)
+  | AugErrLabel                        (** Invalid label *)
+  | AugErrCpDesc               (** Cannot copy node into its descendant *)
+  | AugErrUnknown of int
+  (** Possible error codes. *)
+
+exception Error of error_code * string * string * string
+  (** This exception is thrown when the underlying Augeas library
+      returns an error.  The tuple represents:
+      - the Augeas error code
+      - the ocaml-augeas error string
+      - the human-readable explanation of the Augeas error, if available
+      - a string with details of the Augeas error
+   *)
+
 type path = string
   (** A path expression.