/// <summary> /// Handles the exception. /// </summary> /// <param name="e">The e.</param> private static void HandleException(Exception e) { if (e.Message.IndexOf("timeout", StringComparison.InvariantCultureIgnoreCase) != -1) { LogConsumer.Trace(e); } else { LogConsumer.Handle(e); } }
/// <summary> /// Handles the extension. /// </summary> /// <param name="e">The e.</param> /// <param name="cacheKey">The cache key.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> private static bool HandleExtension(Exception e, string cacheKey) { TelemetryAnalytics.TrackMetric("SMTPError", e.Message); if (e.InnerException?.InnerException is SocketException || e.Message.IndexOf(@"4.7.1", StringComparison.InvariantCultureIgnoreCase) != -1 || e.Message.IndexOf(@"5.0.3", StringComparison.InvariantCultureIgnoreCase) != -1) { CacheManager.Set(true, cacheKey, new TimeSpan(0, 15, 0)); return(true); } if (e.Message.IndexOf(@"4.4.2", StringComparison.InvariantCultureIgnoreCase) != -1 || e.Message.IndexOf(@"4.7.0", StringComparison.InvariantCultureIgnoreCase) != -1) { return(false); } LogConsumer.Handle(e); return(true); }
/// <summary> /// Handles the specified exception. /// </summary> /// <param name="exception">The exception.</param> public static void Handle(Exception exception) { try { //Tries to log the exception using CrispyWaffle framework behavior ServiceLocator .Resolve <DefaultExceptionHandler>() .AddLogProvider <EventLogProvider>(ExceptionLogType.FULL); LogConsumer.Handle(exception); } catch (Exception ex) { var builder = new StringBuilder() .AppendFormat("Original exception: {0}\r\n", GetMessage(exception)) .AppendFormat("Current exception: {0}", GetMessage(ex)); System.IO.File.WriteAllText($@"fatal-{DateTime.Now:yyyyMMddHHmmss}.log", builder.ToString(), Encoding.UTF8); } }
/// <summary> /// Adds the attachment. /// </summary> /// <param name="attachment">The attachment.</param> /// <exception cref="NullMessageException"></exception> public void AddAttachment(Attachment attachment) { if (!_messageSet) { throw new NullMessageException(); } if (_htmlMessage.Length > 150000) { return; } try { _message.Attachments.Add(attachment); } catch (Exception e) { LogConsumer.Handle(e); } }