1(** Error types and exception handling for GPX operations *)
2
3(** Main error type *)
4type t =
5 | Invalid_xml of string (** XML parsing/structure error *)
6 | Invalid_coordinate of string (** Coordinate validation error *)
7 | Missing_required_attribute of string * string (** Missing XML attribute (element, attr) *)
8 | Missing_required_element of string (** Missing XML element *)
9 | Validation_error of string (** GPX validation error *)
10 | Xml_error of string (** Lower-level XML error *)
11 | IO_error of string (** File I/O error *)
12
13(** GPX exception *)
14exception Gpx_error of t
15
16(** Result type for operations that can fail *)
17type 'a result = ('a, t) Result.t
18
19(** {2 Error Operations} *)
20
21(** Convert error to human-readable string *)
22val to_string : t -> string
23
24(** Pretty print error *)
25val pp : Format.formatter -> t -> unit
26
27(** Compare errors *)
28val compare : t -> t -> int
29
30(** Test error equality *)
31val equal : t -> t -> bool
32
33(** {2 Error Constructors} *)
34
35(** Create invalid XML error *)
36val invalid_xml : string -> t
37
38(** Create invalid coordinate error *)
39val invalid_coordinate : string -> t
40
41(** Create missing attribute error *)
42val missing_attribute : string -> string -> t
43
44(** Create missing element error *)
45val missing_element : string -> t
46
47(** Create validation error *)
48val validation_error : string -> t
49
50(** Create XML error *)
51val xml_error : string -> t
52
53(** Create IO error *)
54val io_error : string -> t
55
56(** {2 Result Helpers} *)
57
58(** Convert exception to result *)
59val catch : ('a -> 'b) -> 'a -> 'b result
60
61(** Convert result to exception *)
62val get_exn : 'a result -> 'a
63
64(** Map over result *)
65val map : ('a -> 'b) -> 'a result -> 'b result
66
67(** Bind over result *)
68val bind : 'a result -> ('a -> 'b result) -> 'b result
69
70(** Convert string result to error result *)
71val from_string_result : ('a, string) Result.t -> 'a result
72
73(** {2 Error Classification} *)
74
75(** Check if error is XML-related *)
76val is_xml_error : t -> bool
77
78(** Check if error is coordinate-related *)
79val is_coordinate_error : t -> bool
80
81(** Check if error is validation-related *)
82val is_validation_error : t -> bool
83
84(** Check if error is IO-related *)
85val is_io_error : t -> bool