Exemplo n.º 1
0
        public void ProcessCall(ISocketWrapper socketWrapper)
        {
            var result = socketWrapper.PeekToString(9);

            Exception caughtException = null;

            // TODO: Add exception handlers for custom exceptions and pass
            //       the exceptions to the respective return processor
            //       Ex: BadRequestException -> HttpBadRequestReturnController
            try
            {
                IHttpCallProcessor callProcessor = VerifyAndExtractProcessor(result);
                callProcessor.ProcessCall(socketWrapper);
            }
            catch (Exception ex)
            {
                if (_exceptionHandler.HasResponse(ex.GetType().Name) == false)
                {
                    throw;
                }
                caughtException = ex;
            }

            IHttpResponse response = null;

            if (caughtException != null)
            {
                response = _exceptionHandler.GetResponseFromException(caughtException);
            }
        }
Exemplo n.º 2
0
        public void ProcessCall(INetworkStreamWrapper socketWrapper)
        {
            var result = socketWrapper.PeekToString(9);

            Exception     caughtException = null;
            IHttpResponse response        = null;

            try
            {
                IHttpCallProcessor callProcessor = VerifyAndExtractProcessor(result);
                response = callProcessor.ProcessCall(socketWrapper);
            }
            catch (Exception ex)
            {
                if (_exceptionHandler.HasResponse(ex.GetType().Name) == false)
                {
                    throw;
                }
                response = _exceptionHandler.GetResponseFromException(caughtException);
            }

            SendResponse(response, socketWrapper);
        }