package eio

  1. Overview
  2. Docs
Effect-based direct-style IO API for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

eio-1.5.tbz
sha256=7d70d1f5fb2b7190bf1ab28fffeb272da51ffe6d6c9c7c94e0485fabdf3b3fda
sha512=4582ac2fb2f8616b3d8ae9670eb7913a78085899b14044408801b30a34fed6c4d32971ba72eedb0cbc3d82c057610cf81c482090e75e2985330fcde96478ac5e

doc/src/eio.unix/err.ml.html

Source file err.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
type Eio.Exn.Backend.t += Unix_error of Unix.error * string * string

let () =
  Eio.Exn.Backend.register_pp (fun f -> function
      | Unix_error (code, name, arg) -> Fmt.pf f "Unix_error (%s, %S, %S)" (Unix.error_message code) name arg; true
      | _ -> false
    )

let unclassified e = Eio.Exn.create (Eio.Exn.X e)

let v code name arg =
  let e = Unix_error (code, name, arg) in
  match code with
  | EUNKNOWNERR x when Some x = Config.enotcapable -> Eio.Fs.err (Permission_denied e)
  | ECONNREFUSED -> Eio.Net.err (Connection_failure (Refused e))
  | ECONNRESET | EPIPE | ECONNABORTED -> Eio.Net.err (Connection_reset e)
  | ENOPROTOOPT -> Eio.Net.err Invalid_option
  | ENOSYS | EOPNOTSUPP -> Eio.Exn.create (Eio.Exn.Not_available e)
  | EEXIST -> Eio.Fs.err (Already_exists e)
  | ENOENT -> Eio.Fs.err (Not_found e)
  | EXDEV | EACCES | EPERM -> Eio.Fs.err (Permission_denied e)
  | _ -> unclassified e