public void Process(ExceptionArgs args) { if (args == null) { return; } var publications = _service.GetApplicablePublications(new Guid(Constants.PipelineEventIds.ApplicationMvcException)); if (!publications.Any()) { return; } var message = $"MVC error occured on item {args.PageContext.Item.Paths.Path}. \n" + $"{args.Message} \n"; foreach (var publication in publications) { foreach (var channel in publication.GetChannels()) { _message.Text = message; _message.UpdateChannelInfo(channel, publication); _service.PublishMessage(_message); } } }
protected virtual void RaiseMonitorExceptionEvent(ExceptionArgs e) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. OnMonitorException?.Invoke(this, e); }
public override void Process(ExceptionArgs args) { var context = args.ExceptionContext; var httpContext = context.HttpContext; var exception = context.Exception; if (context.ExceptionHandled || httpContext == null || exception == null) { return; } Log.Error(string.Format("There was an error in {0} : {1}", Context.Site.Name, exception), this); // Return a 500 status code and execute the custom error page. HttpContext.Current.Server.ClearError(); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.TrySkipIisCustomErrors = true; HttpContext.Current.Response.StatusCode = 500; HttpContext.Current.Response.StatusDescription = "Internal Exception"; var serverErrorPage = _sitecoreContext.ServerErrorPage; var targetUrl = UrlUtil.GetPageNotFoundItem(serverErrorPage); string content = WebUtil.ExecuteWebPage(targetUrl); // write out 500 page html content HttpContext.Current.Response.Write(content); HttpContext.Current.Response.Redirect(targetUrl); HttpContext.Current.Response.End(); }
//Due to the much higher possibilty of very high rate logging at the debug level and wanting to //avoid any possibilty of adding exceptions to debugging attempts, these are wrapped in try/catches. Thread pool //enqueues have OOM as a documented exception, and of course who knows what undocumented exceptions might be thrown public void Debug(object message, Exception exception) { if (!IsDebugEnabled) { return; } try { ExceptionArgs eargs = new ExceptionArgs(message, exception); if (UseSyncLogging) { DoDebugException(eargs); } else { ThreadPool.UnsafeQueueUserWorkItem(DoDebugException, eargs); } } catch (Exception e) { _log.ErrorFormat("Could not enqueue debug log write for message \"{0}: {1}\" due to exception {2}", message, exception, e); } }
public void Run(Action action, Func <BaseForm, ExceptionArgs, ExceptionArgs> onActionException = null) { try { action?.Invoke(); } catch (Exception ex) { ExceptionArgs args = onActionException?.Invoke(this, new ExceptionArgs(ex)); if (args == null) { HandleEx(ex); } else { if (!args.IsHandled) { HandleEx(ex); } if (args.Retrow) { throw; } } } }
public void OnExceptionIsExecutedWhenApiResultHasException() { Logger logger = new Logger(); ExceptionArgs exceptionArgs = null; FlushLogArgs flushArgs = FlushLogArgsFactory.Create(new[] { logger }); CreateRequestLogRequest request = PayloadFactory.Create(flushArgs); var kisslogApi = new Mock <IPublicApi>(); kisslogApi.Setup(p => p.CreateRequestLog(It.IsAny <CreateRequestLogRequest>(), It.IsAny <IEnumerable <File> >())) .Returns(new ApiResult <RequestLog> { Exception = new ApiException { ErrorMessage = $"Error {Guid.NewGuid()}" } }); FlushOptions options = new FlushOptions { UseAsync = false, OnException = (ExceptionArgs args) => { exceptionArgs = args; } }; Flusher.FlushAsync(options, kisslogApi.Object, flushArgs, request).ConfigureAwait(false); Assert.IsNotNull(exceptionArgs); }
public void ShowException(object sender, ExceptionArgs e) { MessageBox.Show(e.Text, e.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); onClose(this, new FormClosedEventArgs(CloseReason.None)); }
private void ShowException(object sender, ExceptionArgs args) { var ex = args.Value; Invoke(new Action(() => { stripStatusLabel.Text = string.Format("An error occurred: {0}", ex.Message); })); }
internal void DoErrorException(object state) { ExceptionArgs args = state as ExceptionArgs; if (args != null) { _log.Error(args.Message, args.ThisException); } }
public void Process(ExceptionArgs exceptionArgs) { if (exceptionArgs.ExceptionContext.ExceptionHandled) { return; } this.HandleException(exceptionArgs.ExceptionContext); }
public void ConstructorUpdatesTheProperties() { FlushLogArgs flushLogArgs = CommonTestHelpers.Factory.CreateFlushLogArgs(); ApiResult apiResult = new ApiResult(); var result = new ExceptionArgs(flushLogArgs, apiResult); Assert.AreSame(flushLogArgs, result.FlushArgs); Assert.AreSame(apiResult, result.ApiResult); }
private void PrintMUBAndTTLabels_OnPrintTTLabelException(object sender, ExceptionArgs e) { _PrintMUBSucceed = false; _PrintTTSucceed = false; //this._web.RunScript("$('#WaitingSection').hide();$('#CompletedSection').hide(); ; "); //this._web.RunScript("$('.status-text').css('color','#000').text('Sent problem to Duty Officer. Please wait to check !');"); //MessageBox.Show(e.ErrorMessage, "", MessageBoxButtons.OK, MessageBoxIcon.Error); Trinity.SignalR.Client.Instance.SendToAllDutyOfficers(((Trinity.BE.User)Session.Instance[CommonConstants.USER_LOGIN]).UserId, "MUB & TT", "Don't print MUB & TT, Please check !", EnumNotificationTypes.Error); //DeleteQRCodeImageFileTemp(); //LogOut(); }
public override void Process(ExceptionArgs args) { // if not configured to show friendly errors, // do not handle any exceptions. if (SCSettings.CustomErrorsMode == System.Web.Configuration.CustomErrorsMode.Off || (SCSettings.CustomErrorsMode == System.Web.Configuration.CustomErrorsMode.RemoteOnly && args.ExceptionContext.HttpContext.Request.IsLocal)) { return; } else { HandleError(args.ExceptionContext); } }
public async Task PostExeceptionAsync(ExceptionArgs ex) { var lookup = @"SELECT ID FROM dbo.KeyGuid WHERE [Key] = @key"; var sql = @"INSERT INTO dbo.Exceptions (SourceGuid, ExString) VALUES (@MyGuid, @Myexception)"; using (var conn = new SqlConnection(sqlConnectionStringBuilder.ConnectionString)) { if (ex.MyGuid == Guid.Empty && !string.IsNullOrEmpty(ex.Key)) { var x = conn.ExecuteScalar <Guid>(lookup, new { Key = ex.Key }); ex.MyGuid = x; } _ = await conn.ExecuteAsync(sql, new { ex.MyGuid, ex.Myexception }); } }
public void Error(object message, Exception exception) { if (!IsErrorEnabled) { return; } ExceptionArgs eargs = new ExceptionArgs(message, exception); if (UseSyncLogging) { DoErrorException(eargs); } else { ThreadPool.UnsafeQueueUserWorkItem(DoErrorException, eargs); } }
public void Process(ExceptionArgs args) { if (args == null) return; var publications = _service.GetApplicablePublications(new Guid(Constants.PipelineEventIds.ApplicationMvcException)); if (!publications.Any()) return; var message = $"MVC error occured on item {args.PageContext.Item.Paths.Path}. \n" + $"{args.Message} \n"; foreach (var publication in publications) { foreach (var channel in publication.GetChannels()) { _message.Text = message; _message.UpdateChannelInfo(channel, publication); _service.PublishMessage(_message); } } }
protected override bool ShowErrorMessage(ExceptionContext exceptionContext, ExceptionArgs args) { if (this.GetResponse(args) == null || Sitecore.Context.RawUrl.StartsWith("/sitecore/")) { return(false); } else { // if the error page threw the error, do not handle it. if (args.PageContext.Item.TemplateID == new ID("{455B0CD7-43EE-4553-A7AD-FFFC1DA2143E}")) { return(false); } HttpContext.Current.Session["Last Exception"] = exceptionContext.Exception; HttpContext.Current.Response.Redirect("/error", true); return(true); } }
public override void Process(ExceptionArgs args) { try { var site = Context.Site; if (site == null) { return; } var enableHandleCustomErrors = MainUtil.GetBool(site.Properties[Constants.SiteInfo.Properties.EnableHandleCustomErrors], false); if (!enableHandleCustomErrors) { return; } var context = args.ExceptionContext; var httpContext = context.HttpContext; var exception = context.Exception; if (context.ExceptionHandled || httpContext == null || exception == null) { return; } var errorPageUrl = site.Properties[Constants.SiteInfo.Properties.CustomErrorFile]; if (string.IsNullOrWhiteSpace(errorPageUrl)) { return; } httpContext.Server.ClearError(); httpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; httpContext.Server.Execute(errorPageUrl); } catch (Exception ex) { Log.Error($"{this} {typeof(Process)} : {ex.Message}'", ex, this); Log.Error($"{this} {typeof(Process)} : {ex.StackTrace}'", ex, this); } }
static async void ChatsServices_ErrorConexion(object sender, ExceptionArgs e) { await ReconectarChatHub(); }
public void Process_HandledException_DontSetView(FakeSiteContext siteContext, InvalidDatasourceItemExceptionProcessor processor, [Modest] ExceptionContext exceptionContext, [Substitute] ExceptionArgs exceptionArgs) { //Arrange typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Edit); exceptionArgs.ExceptionContext.ExceptionHandled = true; //Act using (new SiteContextSwitcher(siteContext)) { processor.Process(exceptionArgs); //Assert exceptionArgs.ExceptionContext.Result.Should().BeOfType <EmptyResult>(); } }
public void NullApiResultThrowsException() { FlushLogArgs flushLogArgs = CommonTestHelpers.Factory.CreateFlushLogArgs(); var result = new ExceptionArgs(flushLogArgs, null); }
private void PrintMUBAndTTLabels_OnPrintTTLabelException(object sender, ExceptionArgs e) { //MessageBox.Show(e.ErrorMessage, "", MessageBoxButtons.OK, MessageBoxIcon.Error); DeleteQRCodeImageFileTemp(); }
public void Handle(ExceptionArgs args) => Console.WriteLine($"{args.TimeStamp} {args.ProcessId} {args.TypeName} {args.Message}");
public void NullFlushLogArgsThrowsException() { var result = new ExceptionArgs(null, new RestClient.ApiResult()); }
/// <summary> /// Информирование об исключении /// </summary> private static void ShowException(object sender, ExceptionArgs ex_args) { Console.WriteLine(ex_args.Text); }
public void Process_DataSourceException_LogError(Database db, FakeSiteContext siteContext, InvalidDatasourceItemExceptionProcessor processor, [Modest] ExceptionContext exceptionContext, [Substitute] ExceptionArgs exceptionArgs, [Modest] InvalidDataSourceItemException exception, MemoryAppender appender) { //Arrange typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Edit); BasicConfigurator.Configure(appender); exceptionArgs.ExceptionContext.ExceptionHandled = false; exceptionArgs.ExceptionContext.Exception = exception; //Act using (new SiteContextSwitcher(siteContext)) { processor.Process(exceptionArgs); //Assert appender.Events.Should().Contain(x => x.RenderedMessage.Contains(exception.Message)); } }
public void Process_DataSourceExceptionInNormalMode_HandleException(FakeSiteContext siteContext, InvalidDatasourceItemExceptionProcessor processor, [Modest] ExceptionContext exceptionContext, [Substitute] ExceptionArgs exceptionArgs, [Modest] InvalidDataSourceItemException exception) { //Arrange typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Normal); exceptionArgs.ExceptionContext.ExceptionHandled = false; exceptionArgs.ExceptionContext.Exception = exception; //Act using (new SiteContextSwitcher(siteContext)) { processor.Process(exceptionArgs); //Assert exceptionArgs.ExceptionContext.ExceptionHandled.Should().BeTrue(); exceptionArgs.ExceptionContext.Result.Should().BeOfType <EmptyResult>(); } }
/// <summary> /// Processes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> public override void Process(ExceptionArgs args) { HandleError(args.ExceptionContext); }
public void Process_DataSourceExceptionInEditMode_SetView(Database db, FakeSiteContext siteContext, InvalidDatasourceItemExceptionProcessor processor, [Modest] ExceptionContext exceptionContext, [Substitute] ExceptionArgs exceptionArgs, [Modest] InvalidDataSourceItemException exception) { //Arrange typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Edit); exceptionArgs.ExceptionContext.ExceptionHandled = false; exceptionArgs.ExceptionContext.Exception = exception; //Act using (new SiteContextSwitcher(siteContext)) { processor.Process(exceptionArgs); //Assert exceptionArgs.ExceptionContext.Result.Should().BeOfType <ViewResult>().Which.ViewName.Should().Be(ViewPath.InfoMessage); exceptionArgs.ExceptionContext.ExceptionHandled.Should().BeTrue(); } }