Improve error reporting on init
[ocaml-augeas.git] / augeas.ml
index b7e1c58..7601200 100644 (file)
--- a/augeas.ml
+++ b/augeas.ml
 
 type t
 
-exception Error of string
-
 type flag =
   | AugSaveBackup
   | AugSaveNewFile
   | AugTypeCheck
+  | AugNoStdinc
+  | AugSaveNoop
+  | AugNoLoad
+  | AugNoModlAutoload
+  | AugEnableSpan
+  | AugNoErrClose
+  | AugTraceModuleLoading
+
+type error_code =
+  | AugErrInternal
+  | AugErrPathX
+  | AugErrNoMatch
+  | AugErrMMatch
+  | AugErrSyntax
+  | AugErrNoLens
+  | AugErrMXfm
+  | AugErrNoSpan
+  | AugErrMvDesc
+  | AugErrCmdRun
+  | AugErrBadArg
+  | AugErrLabel
+  | AugErrCpDesc
+  | AugErrUnknown of int
+
+type transform_mode =
+  | Include
+  | Exclude
+
+exception Error of error_code * string * string * string
 
 type path = string
 
@@ -45,8 +72,18 @@ external rm : t -> path -> int
   = "ocaml_augeas_rm"
 external matches : t -> path -> path list
   = "ocaml_augeas_match"
+external count_matches : t -> path -> int
+  = "ocaml_augeas_count_matches"
 external save : t -> unit
   = "ocaml_augeas_save"
+external load : t -> unit
+  = "ocaml_augeas_load"
+external set : t -> path -> value option -> unit
+  = "ocaml_augeas_set"
+external transform : t -> string -> string -> transform_mode -> unit
+  = "ocaml_augeas_transform"
+external source : t -> path -> path option
+  = "ocaml_augeas_source"
 
 let () =
-  Callback.register_exception "Augeas.Error" (Error "")
+  Callback.register_exception "Augeas.Error" (Error (AugErrInternal, "", "", ""))