Skip to content

Instantly share code, notes, and snippets.

@ldaniel
Created January 25, 2012 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldaniel/1677871 to your computer and use it in GitHub Desktop.
Save ldaniel/1677871 to your computer and use it in GitHub Desktop.
Tratando erros no Delphi
var
saldo, indice : Integer;
begin
try
indice := 0;
saldo := 1;
saldo := saldo div indice;
ShowMessage('1 / 0 = ' + IntToStr(saldo));
except
on E : EConvertError do
ShowMessage('Erro de conversão: ' + E.Message);
On E : EDivByZero do
ShowMessage('Erro de divisão por zero: ' + E.Message);
// capturando qualquer outro erro
else
ShowMessage('Outro erro...');
end;
finally
// rotinas finais aqui
end;
end;
@martinusso
Copy link

Esse try .. except ... finally funciona em alguma versão do Delphi?

Muito interessante!

Copy link

ghost commented Jul 6, 2012

Qual a sua dúvida?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment