package win-error

  1. Overview
  2. Docs
Windows system error codes

Install

Dune Dependency

Authors

Maintainers

Sources

0.3.tar.gz
sha256=5868d38977c4a9487b22f17d5e13a13abda9c051874715b1c546e59489d0890e
md5=7f3db92cc61ebc5373c4c40d9345961a

Description

If your application is likely to run on Windows, simply replace uses of Unix.error_message with Win_error.error_message for enhanced error reporting. Note this code is platform-agnostic so can be linked into Unix applications too.

Published: 14 Jun 2018

README

ocaml-win-error: manipulate Windows system errors

If your application is likely to run on Windows, simply replace uses of Unix.error_message with Win_error.error_message. When the application runs on Windows, Windows system errors will be decoded; when the application runs elsewhere then the existing Unix.error_message function is called transparently.

A simple example:

try
  let fd = Unix.openfile "/tmp/foo" [ Unix.O_RDONLY ] 0 in
  Unix.close fd
with
| Unix.Unix_error(e, _, _) ->
  Printf.fprintf stderr "Caught: %s\n%!" (Win_error.error_message e)

What's going on?

Errors are typically first thrown by the OCaml standard library as Unix.Unix_error exceptions. In some cases these are mapped onto their Unix equivalents on such as Unix.ENOENT, but when the code isn't recognised OCaml will raise Unix.EUNKNOWNERR (-code). This library is able to convert these codes back into human-readable strings.

Dependencies (4)

  1. jbuilder >= "1.0+beta10"
  2. base-unix
  3. base-bytes
  4. ocaml >= "3.12.1"

Dev Dependencies

None

Used by (3)

  1. protocol-9p = "0.5.2" | >= "0.7.2"
  2. protocol-9p-tool
  3. protocol-9p-unix

Conflicts

None

OCaml

Innovation. Community. Security.