[Quoting Hildo Biersma, on August 4 2000, 08:40, in "Re: try/catch (Was: "]
> Yes, but... this is largely casued by the fact that Java requires you to
> declare any uncaught parameters on your method specification, and this
> tends to have a nasty oil-slick effect.
> 
> If you do it the C++ way, you can say:
> 
>   try {
>     first_sub_that_throws_exceptions();
>     second_sub_that_throws_exceptions();
>   } catch {
>     it went wrong 
>   }

How does 'it went wrong' know _which_ of the subs went wrong? For
example:

  try {
    open(file1);
    open(file2);
    open(file3);
  } catch {
    error("could not open one of the file(s)");
  }

which is not very helpful to the user. And

  try { open(file1) } catch { error("could not open file1"); }
  try { open(file2) } catch { error("could not open file2"); }
  try { open(file3) } catch { error("could not open file3"); }

is not very helpful to the programmer.

Bottom line: I really appreciate the try/catch mechanism. But let's
learn from C++ and Java how _not_ do do it.

-- Johan

Reply via email to