123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109(*
* Copyright (c) 2022-2022 Tarides <contact@tarides.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)openImportopenErrors(** Error manager for errors and exceptions defined in {!Errors} and
{!Io.S.misc_error} *)moduletypeS=sigmoduleIo:Io.Stypet=[Base.t|`Io_miscofIo.misc_error][@@derivingirmin]valraise_error:[<t]->'avallog_error:string->[<t]->unitvalcatch:(unit->'a)->('a,t)resultvalraise_if_error:('a,[<t])result->'avallog_if_error:string->('a,[<t])result->unitendmoduleMake(Io:Io.S):SwithmoduleIo=Io=structmoduleIo=Io(* Inline the definition of the polymorphic variant for the ppx. *)typet=[`Double_close|`File_existsofstring|`Invalid_parent_directory|`No_such_file_or_directoryofstring|`Not_a_file|`Read_out_of_bounds|`Invalid_argument|`Decoding_error|`Not_a_directoryofstring|`Index_failureofstring|`Invalid_layout|`Corrupted_legacy_file|`Corrupted_mapping_fileofstring|`Pending_flush|`Rw_not_allowed|`Migration_needed|`Migration_to_lower_not_allowed|`Corrupted_control_fileofstring|`Sys_errorofstring|`V3_store_from_the_future|`Gc_forbidden_during_batch|`Unknown_major_pack_versionofstring|`Only_minimal_indexing_strategy_allowed|`Commit_key_is_danglingofstring|`Dangling_keyofstring|`Gc_disallowedofstring|`Node_or_contents_key_is_indexedofstring|`Gc_process_errorofstring|`Corrupted_gc_result_fileofstring|`Gc_process_died_without_result_fileofstring|`Gc_forbidden_on_32bit_platforms|`Invalid_prefix_readofstring|`Invalid_sparse_readof[`After|`Before|`Hole]*int63|`Invalid_volume_readof[`Empty|`Closed]*int63|`Inconsistent_store|`Closed|`Ro_not_allowed|`Io_miscofIo.misc_error|`Split_forbidden_during_batch|`Split_disallowed|`Multiple_empty_chunks|`Forbidden_during_gc|`Multiple_empty_volumes|`Volume_missingofstring|`Volume_history_newer_than_archived_dataofint63*int63|`Lower_has_no_volume|`Add_volume_forbidden_during_gc|`Add_volume_requires_lower|`Volume_not_foundofstring|`No_tmp_path_provided][@@derivingirmin]letraise_error=function|`Io_misce->Io.raise_misc_errore|#errorase->Base.raise_erroreletlog_errorcontexte=[%log.err"%s failed: %a"context(Irmin.Type.ppt)(e:>t)]letcatchf=matchBase.catch(fun()->Io.catch_misc_errorf)with|Ok(Okv)->Okv|Ok(Errore)->Error(e:>t)|Errore->Error(e:>t)letraise_if_error=functionOkx->x|Errore->raise_erroreletlog_if_errorcontext=function|Ok_->()|Errore->log_errorcontexteend