File: err.ml

package info (click to toggle)
ocaml-eio 1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,548 kB
  • sloc: ml: 14,608; ansic: 1,237; makefile: 25
file content (16 lines) | stat: -rw-r--r-- 584 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
let unclassified e = Eio.Exn.create (Eio.Exn.X e)

let wrap code name arg =
  let ex = Eio_unix.Unix_error (code, name, arg) in
  match code with
  | ECONNREFUSED -> Eio.Net.err (Connection_failure (Refused ex))
  | ECONNRESET | EPIPE -> Eio.Net.err (Connection_reset ex)
  | _ -> unclassified ex

let wrap_fs code name arg =
  let e = Eio_unix.Unix_error (code, name, arg) in
  match code with
  | Unix.EEXIST -> Eio.Fs.err (Already_exists e)
  | Unix.ENOENT -> Eio.Fs.err (Not_found e)
  | Unix.EXDEV | EPERM | EACCES -> Eio.Fs.err (Permission_denied e)
  | _ -> wrap code name arg