protected bool OnSendingMessage(RaygunMessage raygunMessage)
{
bool result = true;
if (!_handlingRecursiveErrorSending)
{
EventHandler<RaygunSendingMessageEventArgs> handler = SendingMessage;
if (handler != null)
{
RaygunSendingMessageEventArgs args = new RaygunSendingMessageEventArgs(raygunMessage);
try
{
handler(this, args);
}
catch (Exception e)
{
// Catch and send exceptions that occur in the SendingMessage event handler.
// Set the _handlingRecursiveErrorSending flag to prevent infinite errors.
_handlingRecursiveErrorSending = true;
Send(e);
_handlingRecursiveErrorSending = false;
}
result = !args.Cancel;
}
}
return result;
}