Example #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="VLogServerSideError"/> class.
        /// from a given <see cref="HttpException"/> instance and 
        /// <see cref="HttpContext"/> instance representing the HTTP 
        /// context during the exception.
        /// </summary>
        /// <param name="httpexception">The occurred server side exception</param>
        public VLogServerSideError(HttpException httpexception)
            : this()
        {
            HttpContext context = HttpContext.Current;
            if (httpexception != null && context != null)
            {
                this.ErrorMessage = httpexception.GetErrorMessage();
                this.ErrorDetails = httpexception.GetErrorErrorDetails();

                // Sets an object of a uniform resource identifier properties
                this.SetAdditionalHttpContextInfo(context);
                this.SetAdditionalExceptionInfo(httpexception);

                // If this is an HTTP exception, then get the status code
                // and detailed HTML message provided by the host.
                this.ErrorCode = httpexception.GetHttpCode();

                VLogErrorCode errorcoderule;

                if (VLog.WebErrorCodes.TryGetValue(this.ErrorCode, out errorcoderule) && !errorcoderule.ExcludeFromLogging)
                {
                    this.AddHttpExceptionData(errorcoderule, context, httpexception, errorcoderule);
                }
            }
        }