Sign in Join
Wiki copytemporary

Try/fi

Deutsch · English · Español · Suomi · Русский

Varattu sana try on osa joko try..finally lohkoa tai try..except-lohkoa.

Jos poikkeus tapahtuu, kun koodia suoritetaan try:n ja finally:n välillä, suoritusta jatketaan finally. Jos poikkeusta ei tapahdu, myös finally ja end:n välinen koodi suoritetaan.

pascal
try
  // koodi, joka saattaa aiheuttaa poikkeuksen
finally 
  // suoritetaan aina viimeisenä
end;

Vain poikkeuksen sattuessa except:n ja end:n välinen koodi suoritetaan.

pascal
try
  // koodi, joka saattaa aiheuttaa poikkeuksen
except 
  // toteutetaan vain poikkeus tapauksessa
  on E: EDatabaseError do
    ShowMessage( 'Database error: '+ E.ClassName + #13#10 + E.Message );
  on E: Exception do
    ShowMessage( 'Error: '+ E.ClassName + #13#10 + E.Message );
end;

Katso myös


From the Free Pascal wiki, page "Try/fi", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.