Ver Mensaje Individual
  #7  
Antiguo 24-05-2003
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Algo para reforzar mi punto de vista.

De la ayuda de Delphi

Exceptions provide an elegant way to trap runtime errors without halting the program and without awkward conditional statements. The requirements imposed by exception handling semantics impose a code/data size and runtime performance penalty. While it is possible to raise exceptions for almost any reason, and to protect almost any block of code by wrapping it in a try...except or try...finally statement, in practice these tools are best reserved for special situations.

Exception handling is appropriate for errors whose chances of occurring are low or difficult to assess, but whose consequences are likely to be catastrophic (such as crashing the application); for error conditions that are complicated or difficult to test for in if...then statements; and when you need to respond to exceptions raised by the operating system or by routines whose source code you don't control. Exceptions are commonly used for hardware, memory, I/O, and operating-system errors.

Conditional statements are often the best way to test for errors. For example, suppose you want to make sure that a file exists before trying to open it. You could do it this way:

Código:
try
  AssignFile(F, FileName);
  Reset(F);  // raises an EInOutError exception if file is not found
except
  on Exception do ...
end;
But you could also avoid the overhead of exception handling by using

Código:
if FileExists(FileName) then  // returns False if file is not found; raises no exception
begin
  AssignFile(F, FileName);
  Reset(F);
end;

// Saludos
Responder Con Cita