/// **************************************************************** /// public Initialize /// ---------------------------------------------------------------- /// <summary> /// Initialize per-request data for the context. This method /// MUST be called once per request. Multiple calls will /// re-initialize the contents of the current context. /// /// </summary> /// **************************************************************** public void Initialize() { // // Reset our state. apiVersionMajor is not reset since it will be set in our VersionSupportExtension // contextType = ContextType.Other; exceptionSource = ExceptionSource.Other; userInfo = new UserInfo(); contextID = Guid.NewGuid(); threadID = System.Threading.Thread.CurrentThread.GetHashCode(); // // 738148 - To reduce disk usage, make it configurable as to whether we log change records or not. // logChangeRecords = Config.GetInt("LogChangeRecords", 0) == 0 ? false : true; timeStamp = DateTime.UtcNow; remoteOperator = null; // // In our log, we should never ever see multiple calls to this method // in the same application_request_started/application_request_ended blocks (see global.asax) // In the event log, correct behaviour is: // application_request started: // "Context.Initialize" message // ... (any number of messages) // application_request ended // Debug.Write(SeverityType.Info, CategoryType.Soap, "Context.Initialize"); }
public void OnException(ExceptionSource sourceComponent, UnityAction <XboxLiveException> callback) { if (!this.ErrorCallbacks.ContainsKey(sourceComponent)) { this.ErrorCallbacks.Add(sourceComponent, new List <UnityAction <XboxLiveException> >()); } this.ErrorCallbacks[sourceComponent].Add(callback); }
private static void RaiseEvent(object sender, Exception ex, ExceptionSource source) { var e = new UnhandledExceptionEventArgs(ex, source); UnhandledExceptionCatched?.Invoke(sender, e); if (AutoShowMessage) { ShowMessage(e); } }
public void RemoveCallbackFromComponent(ExceptionSource sourceComponent, UnityAction <XboxLiveException> callback) { if (this.ErrorCallbacks.ContainsKey(sourceComponent)) { if (this.ErrorCallbacks[sourceComponent].Contains(callback)) { this.ErrorCallbacks[sourceComponent].Remove(callback); } } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } ExceptionSource = await _context.ExceptionSource.FirstOrDefaultAsync(m => m.ID == id); if (ExceptionSource == null) { return(NotFound()); } return(Page()); }
public Task HandleException(IWebHandler handler, WebBasePage page, Exception ex) { string type = page == null?handler.GetType().ToString() : page.GetType().ToString(); ExceptionSource source = new ExceptionSource(handler.SourceInfo.Source, type, handler.PageUrl.ToString(), ex); if (LogException || handler.IsPost) { string fileName = ExceptionUtil.LogException(source.Data); source.FileName = fileName; } return(InternalWebUtil.WritePage(null, source, fPageMaker, handler)); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ExceptionSource = await _context.ExceptionSource.FindAsync(id); if (ExceptionSource != null) { _context.ExceptionSource.Remove(ExceptionSource); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public void ThrowException(ExceptionSource sourceComponent, ExceptionType exceptionType, Exception ex) { if (this.ErrorCallbacks.ContainsKey(sourceComponent) && this.ErrorCallbacks[sourceComponent].Count > 0) { var errorToThrow = new XboxLiveException() { Source = sourceComponent, Type = exceptionType, InnerException = ex }; foreach (var callback in this.ErrorCallbacks[sourceComponent]) { callback(errorToThrow); } } }
/// <summary> /// 初始化异常信息类(仅仅是获取异常信息对象) /// </summary> /// <typeparam name="T">入参类</typeparam> /// <param name="namespaceName">当前命名空间名</param> /// <param name="exceptionFun">方法名</param> /// <param name="param">入参类</param> /// <param name="exceptionSource">异常方向,默认是WIP接收</param> /// <param name="msgSource">消息来源,默认是WIPREST服务</param> /// <returns></returns> public static ExceptionInfoEntity GetExceptionInfo <T>(string namespaceName, string exceptionFun, T param, string key1 = "", string key2 = "", ExceptionSource exceptionSource = ExceptionSource.WIPReceive, ExceptionLevel exceptionLevel = ExceptionLevel.BusinessError , string msgSource = WipSource.WIPREST) { ExceptionInfoEntity exception = new ExceptionInfoEntity() { host = WIPCommon.GetHostName(msgSource), key1 = key1, key2 = key2, exceptionLevel = Convert.ToInt32(exceptionLevel).ToString(), //异常级别:默认是业务错误 exceptionFun = namespaceName + "." + exceptionFun, //异常方法名 exceptionSource = Convert.ToInt32(exceptionSource).ToString(), //异常方向 sourceData = JsonConvert.SerializeObject(param), //入参 creator = JwtHelp.GetCurUserName() }; return(exception); }
public IContent WritePage(ISource source, IPageData pageData, OutputData outputData) { ExceptionSource exSource = source.Convert <ExceptionSource>(); string fileName = exSource.FileName; object result; if (string.IsNullOrEmpty(fileName)) { result = new WebErrorResult(exSource.Data.Exception.Message); } else { fileName = Path.GetFileNameWithoutExtension(fileName); string url = AppUtil.ResolveUrl("~/c/plugin/C/Exception?FileName=" + fileName); result = new WebExceptionResult(url); } string json = result.WriteJson(); return(new SimpleContent(ContentTypeConst.JSON, json)); }
public UnhandledExceptionEventArgs(Exception exception, ExceptionSource source) { Exception = exception ?? throw new ArgumentNullException(nameof(exception)); Source = source; }