ocsigen / eliom

Multi-tier framework for programming web and mobile applications in OCaml.
http://eliom.org
Other
298 stars 52 forks source link

improving error message on "cannot wrap" #523

Open bruce-ricard opened 6 years ago

bruce-ricard commented 6 years ago

This is the error message I got when I tried to pull an object from the server in the client. Really not very useful, the backtrace stops at map.ml. I also got a similar message when I forgot to apply Eliom_react.Down.of_react to my react value and it tells me "cannot wrap functional values".

ocsigenserver: ocsigen:main: Exn during page generation (sending 500): (Failure "cannot wrap object values") ocsigenserver: ocsigen:main: backtrace: ocsigenserver: ocsigen:main: Raised at file "map.ml", line 117, characters 16-25

I think that's it's pretty important that the error message gets improved to show precisely where the error is in the code. It took me a while to find where the object was on my client code. It would be really awesome if that was found at compile time, but I guess it's hard to do. About Eliom_react.Down.of_react, wouldn't it be possible to give an other type to the result of the call, so that we are forced at compile type to call it in order to use it on the client?

Drup commented 6 years ago

I can't really comment on the backtrace issue (I suspect Lwt shenanigans) but about the rest:

Detecting the issue at compile time is indeed difficult, I have some long plan terms on that, but I need things like modular implicits, so it's going to take a while. For details, well, see my thesis I guess :p

On Eliom_react.Down ... this is actually what is done more or less in the API. Adding yet another mandatory call would make the API quite unwieldy, I'm afraid. People already tend to complain about APIs with too many conversion function calls.