Created
January 25, 2012 18:48
-
-
Save ldaniel/1677871 to your computer and use it in GitHub Desktop.
Tratando erros no Delphi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Esse try .. except ... finally funciona em alguma versão do Delphi?
Muito interessante!