ygrek / ocurl

OCaml bindings to libcurl
https://ygrek.org/p/ocurl
MIT License
59 stars 32 forks source link

Directly create Curl.Multi.CError exception value #48

Closed dwwoelfel closed 3 years ago

dwwoelfel commented 3 years ago

Curl.Multi.CError is a value with multiple arguments, but it is currently created in curl-helper.c as if it were a value with a single tuple argument.

When I try to access the arguments at runtime, I encounter a segfault.

This PR constructs it as a multi-argument value in curl-helper.c to match the type in curl.ml.

An alternative approach would be to change the type of the exception from exception CError of string * cerror * string to exception CError of (string * cerror * string);

On a related note, the cerror field is a shadowed type and I couldn't find any functions that operate on it. Is it intended to be that way? It seems like there is no way to make use of it right now.

ygrek commented 3 years ago

Thanks, indeed! Cherry-picked as bc46ab368c1a7d8f2f9f62292ce828a162e339bf

On a related note, the cerror field is a shadowed type and I couldn't find any functions that operate on it. Is it intended to be that way? It seems like there is no way to make use of it right now.

the intention is to map it onto ocaml variant one day, it is left abstract until it is actually implemented (I usually do things on by-need basis to avoid YAGNI, in this case only needed to log the error, without the need to compare on it).