caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Silently discarded exceptions?
@ 2002-08-18 14:52 Oliver Bandel
  2002-08-19 13:54 ` Xavier Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Bandel @ 2002-08-18 14:52 UTC (permalink / raw)
  To: caml-list

Hello,

under Ocaml 3.04 following problem occurs:

I have a test on the first char of a string (Position 0).
If the string is "" then normally (in the toplevel) an
exception is thrown.

When compiling with ocamlc, the program does not
mention that there was an Exception: it silently
stops the execution of my test.
When adding a test on String.length and only testing
the first char of the string, if the String.length is > 0,
then the program continues with the expected behaviour.

What is the problem here?

Are some exceptions, mentioned on the toplevel,
not an issue, when using ocamlc?
Or ist this a bug?

Ciao,
   Oliver

P.S.: The exception, which the toplevel throws is:
      Exception: Invalid_argument "String.get"

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Silently discarded exceptions?
  2002-08-18 14:52 [Caml-list] Silently discarded exceptions? Oliver Bandel
@ 2002-08-19 13:54 ` Xavier Leroy
  2002-08-19 17:44   ` Oliver Bandel
  0 siblings, 1 reply; 3+ messages in thread
From: Xavier Leroy @ 2002-08-19 13:54 UTC (permalink / raw)
  To: Oliver Bandel; +Cc: caml-list

> I have a test on the first char of a string (Position 0).
> If the string is "" then normally (in the toplevel) an
> exception is thrown.
> 
> When compiling with ocamlc, the program does not
> mention that there was an Exception: it silently
> stops the execution of my test.

Chances are that your program contains a "try ... with x -> ..."
or "try ... with _ -> ..." that catches the exception arising from the
invalid string access.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Silently discarded exceptions?
  2002-08-19 13:54 ` Xavier Leroy
@ 2002-08-19 17:44   ` Oliver Bandel
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Bandel @ 2002-08-19 17:44 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: caml-list

Hello Xavier,

thanks for your answer.


On Mon, 19 Aug 2002, Xavier Leroy wrote:

> > I have a test on the first char of a string (Position 0).
> > If the string is "" then normally (in the toplevel) an
> > exception is thrown.
> > 
> > When compiling with ocamlc, the program does not
> > mention that there was an Exception: it silently
> > stops the execution of my test.
> 
> Chances are that your program contains a "try ... with x -> ..."
> or "try ... with _ -> ..." that catches the exception arising from the
> invalid string access.


Well, I have now tested the problem again. For this test I
grabbed the code of question out of the ml-file and tested
it again with ocamlc.

The executable has told me the Exception, then.

So, I browsed over my code in the ml-file and found, where
the difference is: In the function with the String.get-
function I did not used   try ... with ... 
but in a function, that calls this function!
(Propagation of exceptions to higher levels of the program...)

I think this could be a possible problem in development
with Ocaml, and maybe it's better to explicitly catch
the exceptions.

I have to look into my code again and check, if
I can use the _ or better do not use it. Maybe
it's better, when I write explicitly matches.

Do you have a hint, how to handle such things in a
clean way, which is useful?

Is it possible to catch exceptions from specific Modules,
and match the exception by the _ ?

For example: If there is an
Invalid_argument "String.get"
can I match on all "String."-exceptions,
like "String._" or so?


TIA,
   Oliver

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-19 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-18 14:52 [Caml-list] Silently discarded exceptions? Oliver Bandel
2002-08-19 13:54 ` Xavier Leroy
2002-08-19 17:44   ` Oliver Bandel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).