@andersfugmann I actually did that initially, but you use Illegal_argument everywhere else.

In my opinion, all instances of Illegal_argument should be changed to OCaml's Invalid_argument. I can prepare a patch.