private static void HandleException(HttpContext context, string exceptionMessage)
        {
            // Construct query result object for serialization.
            QueryResultObject queryResultObject = new QueryResultObject
            {
                HasError = true,
                ErrorMessage = exceptionMessage
            };

            string returnedValue = serializer.Serialize(queryResultObject);
            context.Response.Write(returnedValue);
        }
        /// <summary>
        /// Execute query for specified dynamic page by object id.
        /// </summary>
        /// <param name="dynamicPageService">dynamic page service</param>
        /// <param name="start">start offset of returned results</param>
        /// <param name="limit">total count of returned results</param>
        /// <param name="sortField">sorting field name</param>
        /// <param name="sortDirection">sorting field direction</param>
        /// <param name="errorMessage">error messages response to the client.</param>
        /// <returns>returns json-serialized string from <see cref="QueryResultObject"/></returns>
        private static string ExecuteQuery(IDynamicPage dynamicPageService, int start, int limit, string sortField, string sortDirection, string errorMessage)
        {
            IEnumerable convertedQueryResults = null;
            int totalRecordCount = 0;
            string returnedErrorMessage = errorMessage;

            if (string.IsNullOrEmpty(returnedErrorMessage))
            {
                try
                {
                    QueryParameter queryParameter = QueryParameter.CreateQueryParameter(dynamicPageService, HttpContext.Current.Request.QueryString, start, limit, sortField, sortDirection);

                    // Execute query.
                    QueryResults queryResults = dynamicPageService.Query(queryParameter);
                    convertedQueryResults = ConvertQueryResults(dynamicPageService, queryResults.Results);
                    totalRecordCount = queryResults.RecordCount;
                }
                catch (ValidationException exp)
                {
                    returnedErrorMessage = exp.Message;
                }
                catch (Exception exp)
                {
                    returnedErrorMessage = Resources.DP_UnknownErrorDetail;
                    Logger.Instance(typeof(DynamicPageDataServiceHandler)).Error(exp);
                }
            }

            // Construct query result object for serialization.
            QueryResultObject queryResultObject = new QueryResultObject
            {
                Records = convertedQueryResults,
                TotalRecordCount = totalRecordCount,
                Start = start,
                Limit = limit,
                HasError = !string.IsNullOrEmpty(returnedErrorMessage),
                ErrorMessage = returnedErrorMessage
            };

            return serializer.Serialize(queryResultObject);
        }