try except madness

Posted by on in Blogs

..or should I say “try and accept some madness”?

Today I came across this little gem inside of a CloseQuery event handler of a form:

  try
    CanClose := bIsInitialisationsOver;
  except
    on E: Exception do
    begin
      WriteErrorToLog('Error.Exception - ' + E.Message);
    end;
  end;

CanClose is a boolean variable that is part of the handler. bIsInitialisationsOver is also a boolean variable. One just has to question what some people are thinking when they feel they need to capture an exception of assignment of a boolean to another boolean. Incidentally, this wasn't an isolated example; there were other instances of similar coding style.

Tags: Delphi stuff


Comments

Check out more tips and tricks in this development video: