コード例 #1
0
ファイル: LoaderWorker.cs プロジェクト: aleDsz/AppServer
        /// <summary>
        /// Process endpoint request and retrieve a Rest Response properly
        /// </summary>
        /// <param name="path">Request path</param>
        /// <param name="method">HTTP method</param>
        /// <param name="request">Rest Request</param>
        /// <returns>Rest Response</returns>
        public RestResponse Process(string path, string method, RestRequest request)
        {
            try {
                return(_restProcessor.Process(path, method, request));
            } catch (Exception ex) {
                var exceptionName = ex.InnerException switch {
                    Exception iex => iex.GetType().Name,
                    null => ex.GetType().Name
                };

                IRestExceptionHandler handler = _restProcessor.GetExceptionHandler(exceptionName);

                if (handler != null)
                {
                    return(handler.HandleException(ex.InnerException));
                }

                Logger.Error(ex.Message);

                return(new RestResponse(
                           "Internal Server Error",
                           "plain/text",
                           System.Net.HttpStatusCode.InternalServerError
                           ));
            }
        }
コード例 #2
0
        /// <summary>
        /// Process endpoint request and retrieve a Rest Response properly
        /// </summary>
        /// <param name="path">Request path</param>
        /// <param name="method">HTTP method</param>
        /// <param name="request">Rest Request</param>
        /// <returns>Rest Response</returns>
        public RestResponse Process(string path, string method, RestRequest request)
        {
            try {
                return(_restProcessor.Process(path, method, request));
            } catch (Exception ex) {
                var exceptionName             = ex.InnerException.GetType().Name;
                IRestExceptionHandler handler = _restProcessor.GetExceptionHandler(exceptionName);

                if (handler != null)
                {
                    return(handler.HandleException(ex.InnerException));
                }

                throw ex;
            }
        }