/// <summary>
        /// Handles any exception that occurs for the current request
        /// </summary>
        /// <param name="ex"></param>
        private void HandleException(Exception ex)
        {
            try
            {
                HttpProxyException proxyException = ex as HttpProxyException;
                if (proxyException == null)
                {
                    WebException webException = ex as WebException;

                    //check if we got a web exception
                    if (webException != null)
                    {
                        //handle the exception as web exception
                        if (webException.Status == WebExceptionStatus.TrustFailure || webException.Status == WebExceptionStatus.SecureChannelFailure)
                        {
                            proxyException = new HttpProxyException(HttpStatusCode.BadGateway, "Bad SSL Connection", ServiceCode.OnSecureInvalidCertificate);
                        }
                        else if (webException.Status == WebExceptionStatus.ServerProtocolViolation)
                        {
                            proxyException = new HttpProxyException(HttpStatusCode.BadGateway, "Server Protocol Violation", ServiceCode.ServerProtocolViolation);
                        }
                        else
                        {
                            //the web exception is coming from the client
                            proxyException = new HttpProxyException(HttpStatusCode.GatewayTimeout, "Proxy Error Sending Request to the Site", ServiceCode.ProxyErrorSendingRequestToTheSite);
                        }
                    }
                    else
                    {
                        proxyException = new HttpProxyException(HttpStatusCode.InternalServerError, "AppScan Proxy Internal Error", ServiceCode.ProxyInternalError);
                    }
                }
                string message = String.Format(Resources.ProxyInternalError, _requestInfo.RequestLine);
                HttpServerConsole.Instance.WriteLine(LogMessageType.Error, message);

                ReturnHttpErrorResponse(proxyException);
            }
            catch
            {
                // do nothing
            }
        }
 /// <summary>
 /// Writes a CRWAE message to the clien
 /// </summary>
 /// <param name="proxyException"></param>
 protected void ReturnHttpErrorResponse(HttpProxyException proxyException)
 {
     ReturnHttpErrorResponse(proxyException.StatusCode, proxyException.StatusLine, proxyException.ServiceCode, proxyException.MessageArgs);
 }