package mlgpx
Library and CLI for parsing and generating GPS Exchange (GPX) formats
Install
dune-project
Dependency
Authors
Maintainers
Sources
mlgpx-1.0.0.tbz
md5=5342bb7e601273245a9fe263e5a08770
sha512=cd73b16e988b3ed3cc427a6c6c6d6c9c745adb1eb7efaae3c34e8d006e9c03d9f9d2616cd4118564bd9873903969d3e4053b585e79dbd3e3e7d0f541e2faac83
doc/src/mlgpx.core/error.ml.html
Source file error.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
(** Error types and exception handling for GPX operations *) (** Main error type *) type t = | Invalid_xml of string | Invalid_coordinate of string | Missing_required_attribute of string * string | Missing_required_element of string | Validation_error of string | Xml_error of string | IO_error of string (** GPX exception *) exception Gpx_error of t (** Result type for operations that can fail *) type 'a result = ('a, t) Result.t (** {2 Error Operations} *) (** Convert error to string *) let to_string = function | Invalid_xml msg -> "Invalid XML: " ^ msg | Invalid_coordinate msg -> "Invalid coordinate: " ^ msg | Missing_required_attribute (element, attr) -> Printf.sprintf "Missing required attribute '%s' in element '%s'" attr element | Missing_required_element element -> Printf.sprintf "Missing required element '%s'" element | Validation_error msg -> "Validation error: " ^ msg | Xml_error msg -> "XML error: " ^ msg | IO_error msg -> "IO error: " ^ msg (** Pretty print error *) let pp ppf error = Format.fprintf ppf "%s" (to_string error) (** Create invalid XML error *) let invalid_xml msg = Invalid_xml msg (** Create invalid coordinate error *) let invalid_coordinate msg = Invalid_coordinate msg (** Create missing attribute error *) let missing_attribute element attr = Missing_required_attribute (element, attr) (** Create missing element error *) let missing_element element = Missing_required_element element (** Create validation error *) let validation_error msg = Validation_error msg (** Create XML error *) let xml_error msg = Xml_error msg (** Create IO error *) let io_error msg = IO_error msg (** Compare errors *) let compare e1 e2 = String.compare (to_string e1) (to_string e2) (** Test error equality *) let equal e1 e2 = compare e1 e2 = 0 (** {2 Result Helpers} *) (** Convert exception to result *) let catch f x = try Ok (f x) with Gpx_error e -> Error e (** Convert result to exception *) let get_exn = function | Ok x -> x | Error e -> raise (Gpx_error e) (** Map over result *) let map f = function | Ok x -> Ok (f x) | Error e -> Error e (** Bind over result *) let bind result f = match result with | Ok x -> f x | Error e -> Error e (** Convert string result to error result *) let from_string_result = function | Ok x -> Ok x | Error msg -> Error (Invalid_xml msg) (** {2 Error Classification} *) (** Check if error is XML-related *) let is_xml_error = function | Invalid_xml _ | Xml_error _ -> true | _ -> false (** Check if error is coordinate-related *) let is_coordinate_error = function | Invalid_coordinate _ -> true | _ -> false (** Check if error is validation-related *) let is_validation_error = function | Validation_error _ | Missing_required_attribute _ | Missing_required_element _ -> true | _ -> false (** Check if error is IO-related *) let is_io_error = function | IO_error _ -> true | _ -> false
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>