private void FilterAndSubmit(Exception ex) { if (ShouldSubmit(ex)) { OneTrue.Report(ex); } }
private static void LogException(Exception ex) { if (!string.IsNullOrEmpty(Config.OneTrueErrorAppKey) && !string.IsNullOrEmpty(Config.OneTrueErrorAppSecret)) { OneTrue.Report(ex); } }
public ActionResult SimulatedFailure() { ViewBag.Title = "Hello"; ViewBag.Model = new { state = "Running", Collected = true }; TempData["DemoKey"] = new { Amount = 20000, Expires = DateTime.UtcNow.AddMinutes(5) }; //throw new UnauthorizedAccessException(); try { throw new InvalidOperationException("Tag demo"); } catch (Exception ex) { var collection = new ContextCollectionDTO("User"); collection.Properties.Add("Id", "53338"); collection.Properties.Add("FirstName", "Jonas"); collection.Properties.Add("LastName", "Gauffin"); collection.Properties.Add("UserName", "jgauffin"); var col2 = new ContextCollectionDTO("ViewModel"); col2.Properties.Add("Fake", "Make"); OneTrue.Report(ex, new [] { collection, col2 }); } return(View()); }
private void FilterAndSubmit(string format, Exception ex, object[] args) { if (ShouldSubmit(ex)) { OneTrue.Report(ex, TryFormat(format, args)); } }
public void Warn(string format, Exception ex, params object[] args) { _logger.Warn(format, ex, args); if (MIN_REPORT_LEVEL >= LogLevel.Warning) { OneTrue.Report(ex, TryFormat(format, args)); } }
public void Critical(Exception ex) { _logger.Critical("", ex); if (MIN_REPORT_LEVEL >= LogLevel.Critical) { OneTrue.Report(ex); } }
public void Error(Exception ex) { _logger.Error("", ex); if (MIN_REPORT_LEVEL >= LogLevel.Error) { OneTrue.Report(ex); } }
public ActionResult GenerateError() { try { throw new InvalidOperationException("Hello world"); } catch (Exception ex) { OneTrue.Report(ex); } return(View()); }
protected void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError(); OneTrue.Report(ex); if (ex != null) { StringBuilder errorString = new StringBuilder(); errorString.Append("An error was caught in the Application_Error event.\n"); errorString.Append("Error in: " + (Context.Session == null ? string.Empty : Request.Url.ToString())); errorString.Append("\nError Message: " + ex.Message); if (ex.InnerException != null) { errorString.Append("\nInner Error Message: " + ex.InnerException.Message); } errorString.Append("\n\nStack Trace: " + ex.StackTrace); Server.ClearError(); /* * if(Context.Session != null) * { * //errorString.Append($"Session: Identity name:[{Thread.CurrentPrincipal.Identity.Name}] IsAuthenticated:{Thread.CurrentPrincipal.Identity.IsAuthenticated}"); * } * * log.Error(errorString.ToString()); * * if (Context.Session != null) * { * var routeData = new RouteData(); * routeData.Values.Add("controller", "Error"); * routeData.Values.Add("action", "Error"); * routeData.Values.Add("exception", ex); * * if(ex.GetType() == typeof(HttpException)) * { * routeData.Values.Add("statusCode", ((HttpException)ex).GetHttpCode()); * } * else * { * routeData.Values.Add("statusCode", 500); * } * * Response.TrySkipIisCustomErrors = true; * IController controller = new ErrorController(); * controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData)); * Response.End(); * * }*/ } }
protected void Application_Error() { var ex = Server.GetLastError(); if (ex is ThreadAbortException) { return; } if (!Request.IsLocal) { if (!string.IsNullOrEmpty(OneTrueErrorAppKey) && !string.IsNullOrEmpty(OneTrueErrorAppSecret)) { OneTrue.Report(ex); } } }
public void Execute(HttpErrorReporterContext context) { try { if (ExecuteUserController(context.HttpContext)) { return; } if (ExecuteUserView(context.HttpContext)) { return; } BuiltInViewRender.Render(context); } catch (Exception ex) { OneTrue.Report(ex, new { context.HttpStatusCodeName, context.HttpStatusCode }); } }
static void Main(string[] args) { // Initialization //var url = new Uri("http://localhost/onetrueerror/"); var url = new Uri("http://*****:*****@gauffin.com"); //OneTrue.LeaveFeedback("dbDTmB8cAEus7vwVviH2Zw", feedback); //return; try { throw new InvalidOperationException("mofo"); //throw new InvalidDataException("corrupt data"); } catch (Exception ex) { OneTrue.Report(ex); } }
private void Application_Error(object sender, EventArgs e) { var exception = Server.GetLastError(); var data = ""; if ((Request.InputStream != null) && (Request.InputStream.Length > 0)) { var reader = new StreamReader(Request.InputStream); data = reader.ReadToEnd(); } _logger.Error("Request + " + Request.Url + ", data" + data, exception); if (!ReportToOneTrueError) { return; } var properties = new Dictionary <string, string> { { "Url", Request.Url.ToString() }, { "HttpMethod", Request.HttpMethod } }; if (Request.UrlReferrer != null) { properties.Add("Referer", Request.UrlReferrer.ToString()); } if (data.Length < 30000) { properties.Add("Body", data); } properties.Add("OneTrueTags", "unhandled-exception"); var collection = new ContextCollectionDTO("Request", properties); OneTrue.Report(exception, collection); }
public override void Log(ExceptionLoggerContext context) { var data = ""; if (context.Request.Content != null) { data = context.Request.Content.ReadAsStringAsync().Result; } _logger.Error("Request + " + context.Request.RequestUri + ", data" + data, context.Exception); _logger.Error(context.Exception); if (!WebApiApplication.ReportToOneTrueError) { return; } var properties = new Dictionary <string, string> { { "Url", context.Request.RequestUri.ToString() }, { "HttpMethod", context.Request.Method.Method } }; if (context.Request.Headers.Referrer != null) { properties.Add("Referer", context.Request.Headers.Referrer.ToString()); } if (data.Length < 30000) { properties.Add("Body", data); } var collection = new ContextCollectionDTO("Request", properties); OneTrue.Report(context.Exception, collection); base.Log(context); }
private bool ExecuteUserView(HttpContextBase httpContext) { if (NoUserViews) { return(false); } var controller = new OneTrueErrorController(); var requestContext = new RequestContext(httpContext, _routeData); var model = new OneTrueViewModel { ErrorId = _errorId, Exception = _exception, HttpStatusCode = HttpCode, HttpStatusCodeName = HttpCodeName }; var ctx = new ControllerContext(requestContext, controller); ctx.Controller.ViewData.Model = model; var viewName = GetViewName(ctx, string.Format("~/Views/Error/{0}.cshtml", HttpCodeName), "~/Views/Error/Error.cshtml", "~/Views/Error/General.cshtml", "~/Views/Shared/Error.cshtml"); if (viewName == null) { NoUserViews = true; return(false); } var result = new ViewResult { ViewName = viewName, MasterName = null, ViewData = new ViewDataDictionary <OneTrueViewModel>(model) }; try { result.ExecuteResult(ctx); } catch (InvalidOperationException ex) { if (ex.Message.Contains("HandleErrorInfo")) { requestContext.HttpContext.Response.Write(@"<html> <head> <title>Configuration error</title> </head> <body> <h1>Configuration error</h1> <p>The default ASP.NET MVC error view <code>Shared\Error.cshtml</code> uses <code>HandleErrorInfo</code> as a view model while OneTrueError expects <code>OneTrueViewModel</code>.</p> <p>You have three options:</p> <ol> <li>Change view model in it: <code>@model OneTrueError.Client.AspNet.Mvc5.OneTrueViewModel</code></li> <li>Remove the view <code>Shared\Errors.cshtml</code> to get OneTrueErrors built in error pages.</li> <li>Disable OneTrueErrors error page handling, remove <code>OneTrue.Configuration.DisplayErrorPages();</code> from global.asax.</li> </ol> <h1>Actual error</h1> <pre>" + model.Exception + "</pre></body></html>"); requestContext.HttpContext.Response.ContentType = "text/html"; requestContext.HttpContext.Response.End(); } OneTrue.Report(ex, model); } catch (Exception ex) { OneTrue.Report(ex, model); } return(true); }