Jump to content

Talk:Exception handling syntax

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by AlastairIrvine (talk | contribs) at 07:53, 18 January 2010 (Appropriateness of this page for Wikipedia: new section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

BASIC code example

Shouldn't proper BASIC error handling code always use the RESUME statement?

Else in C++

Hi,

there is a followin snippet of pseudocode in Exception handling:

try {
 line = console.readLine();
 if (line.length() == 0) {
  throw new EmptyLineException("The line read from console was empty!");
 }
 console.printLine("Hello %s!" % line);
} catch (EmptyLineException e) {
 console.printLine("Hello!");
} catch (Exception e) {
 console.printLine("Error: " + e.message());
} else {
 console.printLine("The program ran successfully");
} finally {
 console.printLine("The program terminates now");
}

in indicates that a program can act in some way when everything went successfully and in a different way if something was broken. I am missing in my knowledge how to make that "if error {} else {}". Could you, please, extend and edit this article (at least for C++) so I can learn how to implement it really? Thank you in advance!

Sorry, not all programming languages support that feature. Looking at the article we have here, it seems only Python and Ruby have else, and that we know of no other name for it either.
However, you should note that all of these features can be written in some other way if the direct way is not available. In some cases, you can put to the end of the try block anything you'd want to put to the else block, because the end of the try block is reached only if there weren't exceptions. --TuukkaH 19:53, 25 April 2006 (UTC)[reply]

Appropriateness of this page for Wikipedia

Hello. I just tagged this page with {{Unreferenced}}. It doesn't seem to fit the model of an Encyclopaedia article; maybe it should be moved to WikiBooks?