<d_bot_>
<NULL> You forgot the \`. You also never prefix a constructor by its type, and I don't think these variants ever need prefixes
<d_bot_>
<NULL> So ``raise `Unsupprted_media_type`` should just work
<sim642>
Raising a polymorphic variant? that seems wrong
<sim642>
But you're right that polymorphic variants don't need to be prefixed with anything
<d_bot_>
<pseud> NULL: you're definitely right about the first part 🙂
<d_bot_>
<NULL> I kinda forgot that you only raise exceptions
<sim642>
`Unsupported_media_type just on its own is of that status type
<d_bot_>
<pseud> Yea, I'm really just bumbling about, trying to see if I can play with opium without tearing through entire books of ocaml.
<d_bot_>
<pseud> Have done some F# before, though. So felt I had a shot at "playing by ear", guess not :S
<d_bot_>
<NULL> I guess you should look for Opium's raise, do you really want to raise an OCaml exception ?
<d_bot_>
<NULL> When it comes to OCaml specificities, not prefixing the polymorphic variant should be the only thing to change
<d_bot_>
<pseud> Not sure what I want, ideally I just want to abort further execution and have the server return a 415 unsupported media type error to the requesting client.
<sim642>
I'm not familiar with Opium but it might not use exceptions for that
<d_bot_>
<NULL> I don't know what function you're using, but it should expect a `( Body.t, [ Status.client_error | Status.server_error ] ) Lwt_result.t` somewhere
<sim642>
Rather you'd probably have to create some response object with the alternative non-ok status code
<d_bot_>
<NULL> And you would use `Lwt_result` to pass the error
raskol has quit [Ping timeout: 246 seconds]
Everything has quit [Quit: leaving]
<d_bot_>
<pseud> I think I need to take a step back.
<d_bot_>
<pseud>
<d_bot_>
<pseud> There's an option type in ocaml, like the Maybe monad in haskell. Is there something like Data.either ?
<d_bot_>
<pseud>
<d_bot_>
<pseud> As in, my function can EITHER return this message type, OR some status code indicating an error
<sim642>
There is Either, but Result is more common because it has Ok/Error instead of Left/Right
<d_bot_>
<NULL> There's both an `Either.t` to return two things with a similar status and `result` to return a value or an error (same thing under the hood)
<sim642>
And that Lwt_result probably is a version of result with some lwt sprinkled on top