Esempio n. 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;
        }
Esempio n. 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));
            }
        }