let testTime() =
try
let now = System.DateTime.Now in
if now.Second < 10 then
raise SimpleException
elif now.Second < 30 then
raise (WrongSecond now.Second)
elif now.Second < 50 then
raise (WrongTime (now.Hour, now.Minute, now.Second))
else
failwith "Invalid Second"
with
| SimpleException ->
printf "Simple exception"
| WrongSecond s ->
printf "Wrong second: %i" s
| WrongTime(h, m, s) ->
printf "Wrong time: %i:%i:%i" h m s
| Failure str ->
printf "Error msg: %s" str
testTime()