Sign in Join
Wiki copytemporary

Revision 1 of 1, by GAN on 1-31-2020. The page as it is now.

Try/es

try es parte tanto de un bloque try..finally como de un bloque try..except.

Si tiene lugar una excepción mientras se ejecuta el código entre un try y un finally, la ejecución se resume en finally. Aún si no tiene lugar la excepción, el código entre finally y end se ejecutará siempre.

pascal
try
  // Código que podría generar una excepción.
finally 
  // Será ejecutado siempre como últimas sentencias.
end;

Siempre que tiene lugar una excepción, se ejecutará el código que se encuentra entre except y end.

pascal
try
  // Código que podría generar una excepción
except
  // Esto se ejecutará únicamente si tiene lugar una excepción
  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;

Ver además


From the Free Pascal wiki, page "Try/es", as it stood on 2020-01-31 after a change by GAN, 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.