Skip to content

Commit

Permalink
Merge pull request issuu#10 from whitequark/master
Browse files Browse the repository at this point in the history
Synchronize exception list with zmq.h
  • Loading branch information
andersfugmann committed Apr 22, 2014
2 parents 25456f5 + 0653730 commit 55df097
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 44 deletions.
40 changes: 24 additions & 16 deletions src/ZMQ.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,34 @@
(** Module Exceptions *)

type error =
EINVAL
| EFAULT
| EMTHREAD
| ETERM
| ENODEV
| EADDRNOTAVAIL
| EADDRINUSE
| ENOCOMPATPROTO
| EPROTONOSUPPORT
| EAGAIN
| ENOTSUP
| EFSM
| ENOMEM
| EINTR
| EUNKNOWN
| ENOTSUP
| EPROTONOSUPPORT
| ENOBUFS
| ENETDOWN
| EADDRINUSE
| EADDRNOTAVAIL
| ECONNREFUSED
| EINPROGRESS
| ENOTSOCK
| EMSGSIZE
| EAFNOSUPPORT
| ENETUNREACH
| ECONNABORTED
| ECONNRESET
| ENOTCONN
| ETIMEDOUT
| EHOSTUNREACH
| ENETRESET
| EFSM
| ENOCOMPATPROTO
| ETERM
| EMTHREAD
| EUNKNOWN

exception ZMQ_exception of error * string

let _ =
Callback.register_exception "zmq exception" (ZMQ_exception(EUNKNOWN,"Unkown error"))
Callback.register_exception "ZMQ.ZMQ_exception" (ZMQ_exception(EUNKNOWN, "Unknown error"))

external version : unit -> int * int * int = "caml_zmq_version"

Expand Down
38 changes: 23 additions & 15 deletions src/ZMQ.mli
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@

(** Module Exceptions *)
type error =
EINVAL
| EFAULT
| EMTHREAD
| ETERM
| ENODEV
| EADDRNOTAVAIL
| EADDRINUSE
| ENOCOMPATPROTO
| EPROTONOSUPPORT
| EAGAIN
| ENOTSUP
| EFSM
| ENOMEM
| EINTR
| EUNKNOWN
| ENOTSUP
| EPROTONOSUPPORT
| ENOBUFS
| ENETDOWN
| EADDRINUSE
| EADDRNOTAVAIL
| ECONNREFUSED
| EINPROGRESS
| ENOTSOCK
| EMSGSIZE
| EAFNOSUPPORT
| ENETUNREACH
| ECONNABORTED
| ECONNRESET
| ENOTCONN
| ETIMEDOUT
| EHOSTUNREACH
| ENETRESET
| EFSM
| ENOCOMPATPROTO
| ETERM
| EMTHREAD
| EUNKNOWN

exception ZMQ_exception of error * string

Expand Down
34 changes: 21 additions & 13 deletions src/fail.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,28 @@

/* This table must be synchronized with the variant definition. */
static int const caml_zmq_error_table[] = {
EINVAL,
EFAULT,
EMTHREAD,
ETERM,
ENODEV,
EADDRNOTAVAIL,
EADDRINUSE,
ENOCOMPATPROTO,
EPROTONOSUPPORT,
EAGAIN,
ENOTSUP,
EPROTONOSUPPORT,
ENOBUFS,
ENETDOWN,
EADDRINUSE,
EADDRNOTAVAIL,
ECONNREFUSED,
EINPROGRESS,
ENOTSOCK,
EMSGSIZE,
EAFNOSUPPORT,
ENETUNREACH,
ECONNABORTED,
ECONNRESET,
ENOTCONN,
ETIMEDOUT,
EHOSTUNREACH,
ENETRESET,
EFSM,
ENOMEM,
EINTR
ENOCOMPATPROTO,
ETERM,
EMTHREAD,
};

/* This must be the last value of the variant. */
Expand All @@ -48,7 +56,7 @@ void caml_zmq_raise(int err_no, const char *err_str) {

error_parameters[0] = Val_int(error_to_raise);
error_parameters[1] = caml_copy_string(err_str);
caml_raise_with_args(*caml_named_value("zmq exception"),
caml_raise_with_args(*caml_named_value("ZMQ.ZMQ_exception"),
2, error_parameters);

CAMLreturn0;
Expand Down

0 comments on commit 55df097

Please sign in to comment.