package mlgpx

  1. Overview
  2. Docs

Module Gpx.ErrorSource

Error handling

The Error module provides comprehensive error handling for GPX operations:

  • XML parsing and validation errors
  • Coordinate validation errors
  • Missing required elements or attributes
  • File I/O errors

Error types and exception handling for GPX operations

Sourcetype t =
  1. | Invalid_xml of string
    (*

    XML parsing/structure error

    *)
  2. | Invalid_coordinate of string
    (*

    Coordinate validation error

    *)
  3. | Missing_required_attribute of string * string
    (*

    Missing XML attribute (element, attr)

    *)
  4. | Missing_required_element of string
    (*

    Missing XML element

    *)
  5. | Validation_error of string
    (*

    GPX validation error

    *)
  6. | Xml_error of string
    (*

    Lower-level XML error

    *)
  7. | IO_error of string
    (*

    File I/O error

    *)

Main error type

Sourceexception Gpx_error of t

GPX exception

Sourcetype 'a result = ('a, t) Result.t

Result type for operations that can fail

Error Operations

Sourceval to_string : t -> string

Convert error to human-readable string

Sourceval pp : Format.formatter -> t -> unit

Pretty print error

Sourceval compare : t -> t -> int

Compare errors

Sourceval equal : t -> t -> bool

Test error equality

Error Constructors

Sourceval invalid_xml : string -> t

Create invalid XML error

Sourceval invalid_coordinate : string -> t

Create invalid coordinate error

Sourceval missing_attribute : string -> string -> t

Create missing attribute error

Sourceval missing_element : string -> t

Create missing element error

Sourceval validation_error : string -> t

Create validation error

Sourceval xml_error : string -> t

Create XML error

Sourceval io_error : string -> t

Create IO error

Result Helpers

Sourceval catch : ('a -> 'b) -> 'a -> 'b result

Convert exception to result

Sourceval get_exn : 'a result -> 'a

Convert result to exception

Sourceval map : ('a -> 'b) -> 'a result -> 'b result

Map over result

Sourceval bind : 'a result -> ('a -> 'b result) -> 'b result

Bind over result

Sourceval from_string_result : ('a, string) Result.t -> 'a result

Convert string result to error result

Error Classification

Sourceval is_xml_error : t -> bool

Check if error is XML-related

Sourceval is_coordinate_error : t -> bool

Check if error is coordinate-related

Sourceval is_validation_error : t -> bool

Check if error is validation-related

Sourceval is_io_error : t -> bool

Check if error is IO-related

OCaml

Innovation. Community. Security.