/// <summary> /// Handles the internal. /// </summary> /// <param name="exception">The exception.</param> private static void HandleInternal(Exception exception) { var category = GetCategory(); var exceptions = exception.ToQueue(out var types); foreach (var type in types) { TelemetryAnalytics.TrackException(type); } var messages = exceptions.GetMessages(category, AdditionalProviders.Where(p => p.Item2 == ExceptionLogType.MESSAGE).Select(p => p.Item1).ToList()); foreach (var additionalProvider in AdditionalProviders.Where(p => p.Item2 == ExceptionLogType.FULL)) { additionalProvider.Item1.Error(category, messages); } }
/// <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 exception. /// </summary> /// <param name="exception">The exception.</param> /// <param name="response">The response.</param> /// <param name="uri">The URI.</param> /// <param name="method">The method.</param> /// <param name="data">The data.</param> /// <param name="result">The result.</param> /// <exception cref="UnexpectedApiResponseException"></exception> private Exception HandleException( Exception exception, HttpResponseMessage response, Uri uri, HttpRequestMethod method, string data, string result) { var statusCode = 0; if (response != null) { statusCode = (int)response.StatusCode; } var ex = new UnexpectedApiResponseException(uri, method.ToString(), data, result, statusCode, exception); if (statusCode == 429 || statusCode == 503) { _requestMediator.Reset(); LogConsumer.Warning("HTTP {2} status code on method {0} - uri {1}", method.ToString(), uri, statusCode); Thread.Sleep(60 * 1000); _requestMediator.Set(); return(ex); } if (statusCode != 0 && statusCode != 408 && statusCode != 500 && statusCode != 502) { throw ex; } LogConsumer.Warning("Retrying the {0} request", method.ToString()); TelemetryAnalytics.TrackHit($"VTEX_handle_exception_retrying_{method.ToString()}_request"); return(ex); }
/// <summary> /// Disposes all registrations. /// </summary> public static void DisposeAllRegistrations() { LogConsumer.Trace("Service locator statistics"); var temp = new Dictionary <Type, int>(RegistrationsCalls); foreach (var calls in temp) { TelemetryAnalytics.TrackDependency(calls.Key, calls.Value); } var type = typeof(IDisposable); var instances = RegistrationsCalls .Where(call => call.Value > 0) .SelectMany(call => Registrations.Where(implementation => type.IsAssignableFrom(implementation.Key) && call.Key.IsAssignableFrom(implementation.Key))) .ToList(); foreach (var instance in instances) { ((IDisposable)instance.Value()).Dispose(); } }