public void Dispose() { try { _progressUi.SetValue(_uiMax); } catch (Exception x) { _exceptionLogger.LogException(x, s_logger); } }
public IResult <string> CreateIntraWarehouseOrder(ICreateIntraWarehouseOrderParameters parameters) { try { return(_intraWarehouseOrderServiceProvider.CreateIntraWarehouseOrder(parameters)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult <string>(null, ex.Message)); } }
public IResult <INotebookReturn> GetNotebook(string notebookKey) { try { return(_notebookServiceProvider.GetNotebook(notebookKey)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult <INotebookReturn>(null, ex.Message)); } }
public IResult <string> CreateMillAndWetdown(ICreateMillAndWetdownParameters parameters) { try { return(_millAndWetdownServiceProvider.CreateMillAndWetdown(parameters)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult <string>(null, ex.Message)); } }
public IResult <string> CreateInventoryAdjustment(ICreateInventoryAdjustmentParameters parameters) { try { return(_inventoryAdjustmentsProvider.CreateInventoryAdjustment(parameters)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult <string>(null, ex.Message)); } }
public IResult <IInventoryReturn> GetInventory(FilterInventoryParameters parameters = null) { try { return(_inventoryServiceProvider.GetInventory(parameters)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult <IInventoryReturn>(null, ex.Message)); } }
public IResult <IQueryable <ILocationReturn> > GetRinconLocations() { try { return(_facilityServiceProvider.GetRinconLocations()); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult <IQueryable <ILocationReturn> >(null, ex.GetInnermostException().Message)); } }
IResult IPickInventoryServiceComponent.SetPickedInventory(string contextKey, ISetPickedInventoryParameters parameters) { try { return(_treatmentOrderServiceProvider.SetPickedInventory(contextKey, parameters)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult(ex.Message)); } }
protected async Task CheckServiceResponseAsync(ServiceResponse response, object info, string message) { if (response.Exception != null) { exceptionLogger?.LogException(response.Exception); await notification?.NotifyAsync(NotifyType.WebMessage, new WebMessageNotifyRequest { TargetType = ExceptionNotificationTargetType, Target = ExceptionNotificationTarget, Subject = message, Message = info == null ? "null": JsonConvert.SerializeObject(info, Formatting.Indented), Type = WebMessageType.Danger }); } if (!response.Success) { logger?.Log($"CKManager: {message}. Status ={response.Status} BasePath = {client.BasePath}"); await notification?.NotifyAsync(NotifyType.WebMessage, new WebMessageNotifyRequest { TargetType = ErrorNotificationTargetType, Target = ErrorNotificationTarget, Subject = message, Message = info == null ? "null" : JsonConvert.SerializeObject(info, Formatting.Indented), Type = WebMessageType.Warning }); } }
public void OnException(ExceptionContext filterContext) { var xForwardedFor = filterContext.HttpContext.Request.Headers["X-Forwarded-For"]; var userHostAddress = filterContext.HttpContext.Request.UserHostAddress; var hostAddresses = string.IsNullOrEmpty(xForwardedFor) ? userHostAddress : $"{xForwardedFor},{userHostAddress}"; var allIpAddresses = _multipleIpAddressProvider.GetIpAddresses(hostAddresses); var loggingModel = new MvcLoggingModel() { UserName = filterContext.HttpContext.User.Identity.Name, UserHostAddress = allIpAddresses, RouteData = _routeDataConverter.ConvertRouteData(filterContext.HttpContext.Request.RequestContext .RouteData.Values) }; _exceptionLogger.LogException(filterContext.Exception, loggingModel); if (!filterContext.ExceptionHandled) { filterContext.Result = new ViewResult() { ViewName = "ErrorPage" }; filterContext.ExceptionHandled = true; } }
public async Task <ActionResult <IEnumerable <Supplier> > > Get(int?id) { try { return(Ok(await _getService.GetAsync(id))); } catch (EntityNotFoundException notFoundException) { return(NotFound(notFoundException.Message)); } catch (Exception exception) { _exceptionLogger.LogException(exception, nameof(SuppliersController), _logger); throw; } }
public async Task <ActionResult> Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { try { var user = await UserManager.FindAsync(model.Name, model.Password); if (user != null) { await SignInUser(user); if (user.UserName == "demo") { var address = HttpContext.Request.UserHostAddress; await _userReporter.Log(user, address); } return(Json(new { url = returnUrl, hasErrors = "false" }, JsonRequestBehavior.AllowGet)); } ModelState.AddModelError("", "Неверные имя пользователя или пароль"); } catch (Exception ex) { _exceptionLogger.LogException(ex); ModelState.AddModelError("", "Сервис временно недоступен. Ведутся работы над восстановлением."); } } ViewBag.ReturnUrl = returnUrl; return(PartialView("_Login", model)); }
public IResult <TOutput> Execute(TInput input) { var parseResult = _parser.Parse(input); if (!parseResult.Success) { return(parseResult); } var validateResult = _validator.Validate(parseResult.ResultingObject); if (!validateResult.Success) { return(new InvalidResult <TOutput>(default(TOutput), "The object received could not be validated. As a result, the command could not be executed.")); } var executeResult = ExecuteImplementation(parseResult.ResultingObject); try { UnitOfWork.Commit(); } catch (Exception exception) { if (_exceptionLogger != null) { _exceptionLogger.LogException(exception); } return(new FailureResult <TOutput>()); } return(executeResult); }
/// <inheritdoc /> public void RaiseException(string errorCode, Exception ex, params object[] args) { IErrorDetail expDetail = _exceptionDataProvider.GetExceptionDetail(errorCode); if (!(expDetail.Clone() is IErrorDetail errorDetail)) { return; } _errorDetailLocalizer.LocalizeErrorDetail(errorDetail, args); if (ex != null) { _exceptionLogger.LogException(errorDetail, ex); } RaisedException exception = new RaisedException(errorDetail.Message, ex); ExceptionData exceptionData = HandleException(errorDetail); if (exceptionData != null) { foreach (string key in exceptionData.Keys) { exception.Data[key] = exceptionData[key]; } } throw exception; }
public async Task <CompiledCode> EmitFromCompilationAsync(CompilationWithSource compilation) { try { (byte[] bin, byte[] pdb) = await Compiler.EmitAsync(compilation.CompilationObject); return(new CompiledCode(compilation.Code, bin, pdb)); } catch (Exception e) when(!(e is CompilationErrorException)) { if (exceptionLogger != null) { await exceptionLogger.LogException(e, compilation.Code); } throw; } }
public void LogException(MethodBase methodBase, Exception err, LoggingLevel exceptionLevel) { ILog logger = LogManager.GetLogger(methodBase.DeclaringType); if (ShouldLog(logger, exceptionLevel, methodBase)) { exceptionLogger.LogException(err, false, methodBase.DeclaringType); } }
private void HandleException(Exception ex) { foreach (var cb in _exceptionHandlingConfiguration.ExceptionCallbacks) { cb.Invoke(ex); } _logger.LogException(ex); }
public async Task <ActionResult <IEnumerable <Product> > > Get( int?id, bool withCategory = true, bool withSupplier = true, bool withUnit = true) { try { return(Ok(await _getService.GetAsync(id, withCategory, withSupplier, withUnit))); } catch (EntityNotFoundException notFoundException) { return(NotFound(notFoundException.Message)); } catch (Exception exception) { _exceptionLogger.LogException(exception, nameof(SuppliersController), _logger); throw; } }
protected void Application_Error(Object sender, EventArgs e) { var raisedException = Server.GetLastError(); //Logg exception _exceptionLogger.LogException(raisedException); //Process exception Server.ClearError(); Response.Redirect("/Shared/Error"); }
private void LogOrThrow(Exception ex) { if (_exceptionLogger != null) { _exceptionLogger.LogException(ex); } else { throw ex; } }
public void Dispose() { try { _progressUi.IncrementValue(); } catch (Exception x) { _exceptionLogger.LogException(x, s_logger); } }
public string GetIpAddress(string ipAddress) { try { return(_singleIpAddressProvider.GetIpAddress(ipAddress)); } catch (ServiceException e) { _exceptionLogger.LogException(e); return(string.Empty); } }
public void Intercept(IInvocation invocation) { MethodInfo methodInfo = invocation.MethodInvocationTarget; if (methodInfo == null) { methodInfo = invocation.Method; } //we take the settings from the first attribute we find searching method first //If there is at least one attribute, the call gets wrapped with an exception handler var assemblyAttributes = (ExceptionHandlerAttribute[]) methodInfo.ReflectedType.Assembly.GetCustomAttributes(typeof(ExceptionHandlerAttribute), false); var classAttributes = (ExceptionHandlerAttribute[]) methodInfo.ReflectedType.GetCustomAttributes(typeof(ExceptionHandlerAttribute), false); var methodAttributes = (ExceptionHandlerAttribute[])methodInfo.GetCustomAttributes(typeof(ExceptionHandlerAttribute), false); if (assemblyAttributes.Length == 0 && classAttributes.Length == 0 && methodAttributes.Length == 0) { invocation.Proceed(); } else { ExceptionHandlerAttributeSettings exceptionHandlerAttributeSettings = GetExceptionHandlerSettings(assemblyAttributes, classAttributes, methodAttributes); try { invocation.Proceed(); } catch (Exception err) { exceptionLogger.LogException(err, exceptionHandlerAttributeSettings.IsSilent, methodInfo.ReflectedType); if (exceptionHandlerAttributeSettings.IsSilent) { if (exceptionHandlerAttributeSettings.ExceptionType == null || exceptionHandlerAttributeSettings.ExceptionType == err.GetType()) { invocation.ReturnValue = exceptionHandlerAttributeSettings.ReturnValue; } else { throw; } } else { throw; } } } }
public void Load() { Logger.LogCategory($"{this.GetType().Name}.Load()"); if (!loaded) { Clear(); try { LoadInternal(); Logger.Log($"Updating linked texts ..."); UpdateLinkedTexts(); Logger.Log($"Caching ..."); if (cache != null) { if (!cache.Contains(CacheItemName)) { cache.Add(CacheItemName, _store); } else { Logger.Log($"cache {CacheItemName} already exists."); cache.GetOrSet(CacheItemName, () => _store); } Logger.Log($"succeeded."); } else { Logger.Log($"No cache found."); } loaded = true; } catch (Exception e) { Logger.Log($"load exception:\n{e.ToString("\n")}"); exceptionLogger.LogException(e, $"{this.GetType().Name}.Load()"); } } else { Logger.Log($"Already loaded"); } }
public void Intercept(IInvocation invocation) { MethodInfo methodInfo = invocation.MethodInvocationTarget; if (methodInfo == null) { methodInfo = invocation.Method; } //we take the settings from the first attribute we find searching method first //If there is at least one attribute, the call gets wrapped with a transaction Type attributeType = GetAttributeType(); var classAttributes = (ITransactionAttributeSettings[]) methodInfo.ReflectedType.GetCustomAttributes(attributeType, false); var methodAttributes = (ITransactionAttributeSettings[]) methodInfo.GetCustomAttributes(attributeType, false); if (classAttributes.Length == 0 && methodAttributes.Length == 0) { invocation.Proceed(); } else { TransactionAttributeSettings transactionAttributeSettings = GetTransactionAttributeSettings(methodAttributes, classAttributes); object transactionState = OnEntry(transactionAttributeSettings, null); try { invocation.Proceed(); } catch (Exception err) { CloseUnitOfWork(transactionAttributeSettings, transactionState, err); if (!(err is AbortTransactionException)) { exceptionLogger.LogException(err, transactionAttributeSettings.IsExceptionSilent, methodInfo.ReflectedType); } if (transactionManager.TransactionDepth == 0 && (transactionAttributeSettings.IsExceptionSilent || err is AbortTransactionException)) { invocation.ReturnValue = transactionAttributeSettings.ReturnValue; return; } throw; } transactionState = OnSuccess(transactionAttributeSettings, transactionState); } }
public IResult <TResult> Execute() { try { return(ExecuteImplementation()); } catch (Exception exception) { if (_exceptionLogger != null) { _exceptionLogger.LogException(exception); } return(new FailureResult <TResult>(default(TResult), "An error occurred while attempting to execute the request.")); } }
public Task <Order> GetOrderAsync(int orderId) { var order = new Order(); try { throw new NotImplementedException("This has not been implemented yet"); } catch (Exception ex) { logger.LogException(ex); } return(Task.FromResult <Order>(order)); }
public async Task <Order> GetOrderAsync(int orderId) { var order = new Order(); try { Task <Order> orderDetailsTask = GetOrderDetailsAsync(orderId); Task <Customer> customerTask = customerReader.GetCustomerForOrderAsync(orderId); Task <List <Product> > productTask = productReader.GetProductsForOrderAsync(orderId); await Task.WhenAll(orderDetailsTask, customerTask, productTask) .ContinueWith(task => { logger.LogException(task.Exception); }, TaskContinuationOptions.OnlyOnFaulted) .ConfigureAwait(false); if (orderDetailsTask.IsCompletedSuccessfully && customerTask.IsCompletedSuccessfully && productTask.IsCompletedSuccessfully) { order = orderDetailsTask.Result; order.Customer = customerTask.Result; order.Products = productTask.Result; } } catch (Exception ex) { logger.LogException(ex); } return(order); }
public virtual TRes Invoke(TReq request) { var result = new TRes(); try { InvokeInternal(request, result); } catch (Exception e) { Logger.LogException(e, this.ToString()); result.Exception = e; } return(result); }
public IActionResult Error() //500 numaralı status kodlarda yani C# kodlarının ürettiği exceptionlar için { IExceptionHandlerPathFeature exceptionHandlerPath = HttpContext.Features.Get <IExceptionHandlerPathFeature>(); IHttpRequestFeature httpRequestFeature = HttpContext.Features.Get <IHttpRequestFeature>(); var jsonSerializerSettings = new JsonSerializerSettings(); //Json serileştirme ayarlarımız jsonSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; jsonSerializerSettings.Formatting = Formatting.Indented; var errorDto = new ErrorDto { CreateDate = DateTime.Now, QueryString = exceptionHandlerPath.Path.QueryStringFromUrl(), IsAjaxRequest = HttpContext.Request.IsAjaxRequest(), RequestType = Enum.Parse <RequestType>(httpRequestFeature.Method), StatusCode = 500, Url = exceptionHandlerPath.Path, Username = "******", Exception = JsonConvert.SerializeObject(exceptionHandlerPath.Error, jsonSerializerSettings) }; //Hatayı veritabanına kaydet ErrorLogger.LogException(errorDto); HttpContext.Response.StatusCode = 200; //Eğer istek ajax isteği ise if (errorDto.IsAjaxRequest) { return(Json(new JsonResponse { Status = JsonResponseStatus.Error, Message = "İşlem esnasında bir hata oluştu.", Result = errorDto })); } var errorVM = Mapper.Map <ErrorDto, ErrorVM>(errorDto); errorVM.Message = exceptionHandlerPath.Error.Message; return(View("_Error", errorVM)); }