"ocaml_beginners"::[] handling

View: New views
3 Messages — Rating Filter:   Alert me  

"ocaml_beginners"::[] handling

by codergen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

How can i raise exceptions in ocaml..what will be the code to write your own exception in a function defined..?plz help..


"ocaml_beginners"::[] Re: handling

by Vincent Aravantinos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



--- In ocaml_beginners@..., "sumedha" <sumedhajain@...> wrote:
>
> How can i raise exceptions in ocaml..what will be the code to write your own exception in a function defined..?plz help..

http://caml.inria.fr/pub/docs/manual-ocaml/manual003.html#toc9


"ocaml_beginners"::[] Re: handling

by Sylvain Le Gall-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 27-10-2009, sumedha <sumedhajain@...> wrote:
>
> How can i raise exceptions in ocaml..what will be the code to write your ow=
> n exception in a function defined..?plz help..
>

exception My_error of string;;

let my_fun () =
  raise (My_error "this is an error")
;;

let () =
  try
    my_fun ()
  with My_error str ->
    prerr_endline ("An error: "^str)
;;


Regards,
Sylvain Le Gall