Root > How to... > ...block report sending?

...block report sending?

Previous pageReturn to chapter overviewNext page   

Many times you know that due to user input or other external factors, a line of code will sometimes generate a non-fatal exception in your application. You may not want your mailbox filled with silly bug reports about users entering bad passwords, etc. Using a simple trick you can "hide" these expected exceptions from EurekaLog.

 

 

1. If you want to ignore exception completely.

 

EurekaLog will not trigger if you handle an exception locally with a try/except block. Using such a block means you are expecting an exception in some code and will handle it yourself. You can also choose to silently ignore an exception if it is both expected and non-fatal to your program.

 

Here are two examples. In the first button click handler we will let EurekaLog handle the exception. In the second click handler, we will completely ignore the exception:

 

procedure TForm1.btnELHandlesExceptionClick(Sender: TObject);
begin
  // No try/except block, so EurekaLog will catch it
  raise EMyException.Create('Red Alert! Send this bug report to the developer with EurekaLog!');
end;

 

procedure TForm1.btnLocallyHandledExceptionClick(Sender: TObject);
begin
  try
    raise EMyException.Create('Move along folks; There is nothing to see here.');
  except
    on E: EMyException do
      // Do nothing. EurekaLog will ignore this exception, because we have already handled it with the "on E:..."
      // We could also add code here to take action on the exception with an "on E: EMyException do HandleThisException"
      // We could also re-raise a new exception in our HandleThisException function
  end;
end;

 

See also: How to handle exception?

 

Note that both exceptions will be caught by your IDE debugger's exception notification handler, but only the first one will generate an EurekaLog bug report. You can configure your IDE debugger to ignore certain exception types.

 

See also: How to ignore exception? for other possible ways to ignore exceptions.

 

 

2. If you want to show exception message, but block sending.

 

You need to mark exception as expected exception. Marking exception as expected will disable bug report, sending, while keeps showing dialog to the user (error message).

 

uses
  EEvents; // for RegisterEventExceptionNotify
 
procedure TForm1.Button1Click(Sender: TObject);
begin
  // EMyException will be handled by EurekaLog.
  // However, it would be considered as expected.
  // "details", "send" and "restart" options will not be shown.
  raise EMyException.Create('Move along folks; There is nothing to see here.');
end;
 
procedure ExceptionNotify(const ACustom: Pointer; 

  AExceptionInfo: TEurekaExceptionInfo; 

  var AHandle: Boolean; 

  var ACallNextHandler: Boolean);
begin
  // Mark exception as expected, but allow it to be handled by EurekaLog.

 
  if // this check matches EMyException only, but skips child classes

     AExceptionInfo.ExceptionClass = EMyException.ClassName then 
  begin
    AExceptionInfo.ExpectedContext := -1;
    Exit;
  end;
end;
 
initialization
  RegisterEventExceptionNotify(nil, ExceptionNotify);
end.

 

 

See also: How to mark exception as expected? for other possible ways to mark exception as expected.




Send feedback... Build date: 2021-10-15
Last edited: 2020-08-27
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/how_to_block_report_sending.php