title: displaying custom error message rather than system error message in Delphi
body: <p>I would like my custom error message to show up rather than the one generated by the system.  Specifically, in this case, if the user tries to open a file that is already in use, I would like to catch the error and display my message, but the system always beats me to it and generates the following message: "Project...raised exception class EFOpenError with message 'Cannot open file "File path and name".  The process cannot access the file because it is being used by another process'."  When I close this error message, that is when my message is displayed.  I would like only my message to be displayed.  I do not want the system message displayed.  Is there a way to do this?  My code does not work.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>begin
   //check if input file can be opened
        try
          if OpenDialog1.Execute then
          begin
            Application.ProcessMessages;
            Memo1.Clear;
            try
              Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
              InputFile := TStringList.Create;
              InputFile.LoadFromFile(OpenDialog1.FileName);
              ActiveFileName := ExtractFileName(OpenDialog1.FileName);
              lblActiveFileName.Caption := 'Active File: ' + ActiveFileName;
              mmuDisplayClear.Enabled := True;
              mmuAnalysisOptions.Enabled := True;
            except on
              EFOpenError do //if file does not exist or is in use
              MessageDlgPos('File either does not exist or may be ' +
                   'in use!', mtError, [mbOK], 0, 300, 300);
            end;
          end;
        finally
          mmuDispInstructions.Enabled := True;
          mmuDispData.Enabled := False;
        end;
  end;
  </code></pre>