Beispiel #1
0
        private HttpResponseMessage HandleDocNotFoundEx(DocumentNotFoundException ex)
        {
            var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
            {
                Content      = new StringContent("Document not found"),
                ReasonPhrase = "document_not_found"
            };

            return(resp);
        }
Beispiel #2
0
        public override void OnException(HttpActionExecutedContext actionExecutedContext)
        {
            Exception ex = actionExecutedContext.Exception;

            BucketNotFoundException bEx = ex as BucketNotFoundException;

            if (bEx != null)
            {
                actionExecutedContext.Response = HandleBucketNotFoundEx(bEx);
                return;
            }
            DocumentNotFoundException dEx = ex as DocumentNotFoundException;

            if (dEx != null)
            {
                actionExecutedContext.Response = HandleDocNotFoundEx(dEx);
                return;
            }
            InvalidVersionFormatException ivEx = ex as InvalidVersionFormatException;

            if (ivEx != null)
            {
                actionExecutedContext.Response = HandleInvalidVersionEx(ivEx);
                return;
            }
            ConflictException cfEx = ex as ConflictException;

            if (cfEx != null)
            {
                actionExecutedContext.Response = HandleConflictEx(cfEx);
                return;
            }

            actionExecutedContext.Response = new HttpResponseMessage(HttpStatusCode.InternalServerError)
            {
                Content      = new StringContent("An error occurred, please try again or contact the administrator."),
                ReasonPhrase = "internal_error"
            };
        }