/// <summary> /// Sends mail about the lastly occured error to the admin /// </summary> public static void ReportLastError() { System.Exception ex = System.Web.HttpContext.Current.Server.GetLastError(); string logTextHeader = FormatLogText(ex.GetBaseException().Message); string logTextBody = ex.ToString(); Emailer.SendMail("*****@*****.**", "*****@*****.**", logTextHeader, logTextBody, null); }
public ErrorLogModel(System.Exception e, ExceptionHappenOn exceptionHappenOn = ExceptionHappenOn.Server, string requestData = "") { Exception = e.Message; BaseException = e.GetBaseException()?.Message; StackTrace = e.StackTrace; IsSolve = false; ExceptionHappenOn = exceptionHappenOn; RequestData = requestData; }
private static async Task HandleExceptionAsync( HttpContext context, System.Exception exception) { _logger.LogError(new EventId(exception.HResult), exception, exception.Message); exception = exception.GetBaseException(); var statusCode = (int)HttpStatusCode.InternalServerError; var response = new JsonErrorResponse { Message = "An internal server error has occured." }; if (exception is RestException re) { statusCode = (int)re.Code; if (re.Message != null) { response.Message = re.Message; } } if (_env.IsDevelopment()) { response.DeveloperMessage = $"Exception: {exception.Message} StackTrace: {exception.StackTrace}"; } context.Response.StatusCode = statusCode; context.Response.ContentType = "application/json"; await context.Response.WriteAsync(JsonConvert.SerializeObject(response)); }
/// <summary> /// /// </summary> /// <param name="e"></param> protected GenericException(System.Exception e) : base("Error : " + typeof(T).Name + " , see more detail.(view innerException)", e.GetBaseException()) { log.Error("Error : " + typeof(T).Name + " , see more detail.(view innerException)", e.GetBaseException()); }
/// <summary> /// /// </summary> /// <param name="message"></param> /// <param name="e"></param> protected GenericException(string message, System.Exception e) : base(message, e.GetBaseException()) { log.Error(message, e.GetBaseException()); }