Example #1
0
        /// <summary>Processes the HTTP response unhandled exception.</summary>
        /// <param name="context">The context.</param>
        /// <param name="contextResolver">The context resolver.</param>
        /// <param name="exception">The exception.</param>
        /// <param name="config">The configuration.</param>
        /// <returns></returns>
        public static async Task <bool> ProcessHttpResponseUnhandledException(this ApiRequestContext context, IApiRequestContextResolver contextResolver, Exception exception, IDeepSleepServiceConfiguration config)
        {
            if (exception != null)
            {
                var code = context.HandleException(exception);


                if (config?.OnException != null && exception as ApiException == null)
                {
                    try
                    {
                        await config.OnException(contextResolver, exception).ConfigureAwait(false);
                    }
                    catch { }
                }

                context.Response.StatusCode = code;
            }

            return(true);
        }