Example #1
0
        private void SetExceptionResult(ExceptionContext context)
        {
            ExceptionCodeDetails details = _exceptionCodesDecider.DecideExceptionCode(context.Exception);

            context.Result = details == null
                ? _exceptionManager.ManageException(context.Exception)
                : _exceptionManager.ManageException(details.ExceptionCode, context.Exception, details.Params);

            context.Exception        = null;
            context.ExceptionHandled = true;
        }
Example #2
0
        /// <summary>
        /// Executes the <see cref="ExceptionHandlingMiddleware"/> to catch and handle exception using <see cref="IExceptionManager"/>
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task Invoke(HttpContext context)
        {
            string url          = context.Request.GetDisplayUrl();
            var    requestScope = string.Format("{0} : requestScope - {1}", url, Guid.NewGuid());

            try
            {
                await _next(context);

                //await _actionResultHandler?.HandleActionResult(new ActionResultContext(_exceptionManager, context, requestScope));
            }
            catch (Exception exception)
            {
                ExceptionCodeDetails details = _exceptionCodesDecider.DecideExceptionCode(exception);
                IActionResult        result  = details == null
                    ? _exceptionManager.ManageException(exception)
                    : _exceptionManager.ManageException(details.ExceptionCode, exception, details.Params);

                await _actionResultHandler?.HandleActionResult(new ActionResultContext(context, exception, result));
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            IExceptionManager exceptionManager = CreateExceptionManager();
            ObjectResult      actionResult     = exceptionManager.ManageException(new Exception("Sample Test Exception")) as ObjectResult;
            ExceptionData     exceptionData    = actionResult.Value as ExceptionData;

            Console.Write("Object Result Created with HttpResponseCode " + actionResult.StatusCode
                          + " and value is { EventId=" + exceptionData.EventId
                          + ", EventName=" + exceptionData.EventName
                          + ", ExceptionCode=" + exceptionData.ExceptionCode
                          + ", Message=" + exceptionData.Message + "}");
            Console.ReadKey();
        }
Example #4
0
 public IActionResult Privacy()
 {
     _exceptionManager.ManageException("E6002", new System.ArgumentNullException(), "test");
     return(View());
 }
 public void Delete(int id)
 {
     _exceptionManager.ManageException("E6002", new System.ArgumentNullException(), "test");
 }