0

Coding:

try
StrToInt(inputNumVariables.Text);
except
ShowMessage('Sólo números, por favor');
end;

Being inputNumVariables a TEdit why would it raise and exception if I type in anything different to an integer number in the Text Edit when the try-except block should catch the exception, doesn't it?

diegoaguilar
  • 8,179
  • 14
  • 80
  • 129
  • 6
    This may be because you are testing inside the IDE, see http://stackoverflow.com/questions/7930102/why-is-except-not-catching-this-error – NoChance Jun 15 '13 at 04:55
  • 1
    Sounds familiar. [Delphi Q&A: Why do I continue getting error messages even after I have written an exception handler?](http://www.cs.wisc.edu/~rkennedy/exception-messages) – Rob Kennedy Jun 15 '13 at 05:01
  • 2
    Yes, the IDE debugger catches the exception first, reports it, then the app catches it after the debugger passes it to the app. A better option is to avoid raising the exception in the first place, by using `TryStrToInt()` instead. – Remy Lebeau Jun 15 '13 at 08:30

0 Answers0