Beispiel #1
0
        /// <summary>
        /// Set General Exception
        /// </summary>
        private void SetGeneralExceptionApplicationResponse(HttpActionExecutedContext filterContext)
        {
            ExceptionContent contents = new ExceptionContent
            {
                Message = string.IsNullOrEmpty(filterContext.Exception.Message) ? "Error occured" : filterContext.Exception.Message
            };

            filterContext.Response = new HttpResponseMessage
            {
                StatusCode = System.Net.HttpStatusCode.BadRequest,
                Content    = new StringContent(JsonConvert.SerializeObject(contents))
            };
        }
Beispiel #2
0
        private void SetApplicationResponse(HttpActionExecutedContext filterContext)
        {
            ExceptionContent contents = new ExceptionContent
            {
                Message = filterContext.Exception.Message
            };

            filterContext.Response = new HttpResponseMessage
            {
                StatusCode = System.Net.HttpStatusCode.BadRequest,
                Content    = new StringContent(JsonConvert.SerializeObject(contents))
            };
        }