public static void HandleInterfaceException(Exception ex) { ExceptionHandlerFactory factory = new ExceptionHandlerFactory(); ExceptionhandlerBase handler = factory.GetExceptionHandler(ExceptionHandlerConst.INTERFACE_EXCEPTION_POLICY); handler.HandleException(ex); }
/// <summary> /// Handles the error. /// </summary> /// <param name="exceptionContext">The exception context.</param> protected virtual void HandleError(ExceptionContext exceptionContext) { var httpContext = exceptionContext.HttpContext; // Bail if we can't do anything; propogate the error for further processing. if (httpContext == null) { return; } if (!ShouldRenderErrors(httpContext)) { return; } if (!CustomRenderingBehaviourRequired) { return; } if (exceptionContext.ExceptionHandled) { return; } if (httpContext.IsCustomErrorEnabled) { exceptionContext.ExceptionHandled = true; } var innerException = exceptionContext.Exception; ExceptionHandlerFactory.Create().HandleException(innerException, httpContext); }
public static void HandleServiceException(Exception ex) { ExceptionHandlerFactory factory = new ExceptionHandlerFactory(); ExceptionhandlerBase handler = factory.GetExceptionHandler(ExceptionHandlerConst.SERVICE_EXCEPTION_POLICY); handler.HandleException(ex); }
public void Handle(Exception e) { ExceptionHandlerFactory factory = ExceptionHandlerFactories.GetFactory(e); PublisherList list = factory.GetPublishers(); ExceptionRule rule = factory.GetRule(); rule.Run(e, list); }
public virtual bool HandleException(Exception ex, SearchQueryRequest searchQueryRequest) { ExceptionHandler handler = ExceptionHandlerFactory.Create(Cmdlet, ex); retryHandler.DelegateHandler = handler; return(retryHandler.HandleException(ex, searchQueryRequest)); }
public void CreateOne_Fail_Test() { var handlers = new IExceptionHandler[] { new NotFoundExceptionHandler() }; var factory = new ExceptionHandlerFactory(handlers); Assert.Null(factory.CreateOne(new InvalidOperationException("Not found"))); }
public void CreateOne_Success_Test() { var handlers = new IExceptionHandler[] { new NotFoundExceptionHandler() }; var factory = new ExceptionHandlerFactory(handlers); Assert.Equal(handlers[0], factory.CreateOne(new NotFoundException("Not found"))); }
public ExecuteResult <T> Post <T>(object model) { if (model == null) { throw new Exception("model could not be null"); } try { _request.Timeout = (int)TimeSpan.FromMinutes(15).TotalMilliseconds; _request.ReadWriteTimeout = (int)TimeSpan.FromMinutes(15).TotalMilliseconds; _request.Method = "POST"; _request.ContentType = "application/json"; var jsonObject = JsonConvert.SerializeObject(model); byte[] requestData = Encoding.UTF8.GetBytes(jsonObject); using (Stream requesStream = _request.GetRequestStream()) { requesStream.Write(requestData, 0, requestData.Length); } using (HttpWebResponse response = (HttpWebResponse)_request.GetResponse()) { var responseStream = response.GetResponseStream(); if (responseStream == null) { return new ExecuteResult <T> { Status = response.StatusCode } } ; var responseData = _responseHandler.Handle <T>(responseStream); return(new ExecuteResult <T> { Status = HttpStatusCode.OK, Data = responseData.Data, Content = responseData.Content }); } } catch (Exception ex) { var exceptionHandlerFactory = new ExceptionHandlerFactory(); var exceptionHandler = exceptionHandlerFactory.Create(ex); return(exceptionHandler.Handle <T>(ex)); } }
/// <summary> /// Called when [application error]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void OnError(object sender, EventArgs e) { var application = (HttpApplication)sender; var error = application.Server.GetLastError(); var exceptionHandler = ExceptionHandlerFactory.Create(); var context = new HttpContextWrapper(HttpContext.Current); if (context.IsCustomErrorEnabled) { Logger.Write(new Log(error).GetExceptionInfo(context)); } exceptionHandler.HandleException(error, context); }
public ExecuteResult <T> Get <T>() { try { _request.Timeout = (int)TimeSpan.FromMinutes(15).TotalMilliseconds; _request.ReadWriteTimeout = (int)TimeSpan.FromMinutes(15).TotalMilliseconds; _request.Method = "GET"; _request.ContentType = "application/x-www-form-urlencoded"; using (HttpWebResponse response = (HttpWebResponse)_request.GetResponse()) { var responseStream = response.GetResponseStream(); if (responseStream == null) { return new ExecuteResult <T> { Status = response.StatusCode } } ; var responseData = _responseHandler.Handle <T>(responseStream); return(new ExecuteResult <T> { Data = responseData.Data, Status = response.StatusCode, Content = responseData.Content }); } } catch (Exception ex) { var exceptionHandlerFactory = new ExceptionHandlerFactory(); var exceptionHandler = exceptionHandlerFactory.Create(ex); return(exceptionHandler.Handle <T>(ex)); } }