コード例 #1
0
        public override Response toResponse(RestException exception)
        {
            Response.Status responseStatus = ExceptionHandlerHelper.Instance.getStatus(exception);
            ExceptionDto    exceptionDto   = ExceptionHandlerHelper.Instance.fromException(exception);

            LOGGER.log(Level.WARNING, getStackTrace(exception));

            return(Response.status(responseStatus).entity(exceptionDto).type(MediaType.APPLICATION_JSON_TYPE).build());
        }
コード例 #2
0
        protected internal virtual void Log(Response.Status status, Exception ex)
        {
            UserGroupInformation ugi = KMSMDCFilter.GetUgi();
            string method            = KMSMDCFilter.GetMethod();
            string url = KMSMDCFilter.GetURL();
            string msg = GetOneLineMessage(ex);

            Log.Warn("User:'******' Method:{} URL:{} Response:{}-{}", ugi, method, url, status, msg
                     , ex);
        }
コード例 #3
0
        /// <summary>Logs the HTTP status code and exception in HttpFSServer's log.</summary>
        /// <param name="status">HTTP status code.</param>
        /// <param name="throwable">exception thrown.</param>
        protected internal override void Log(Response.Status status, Exception throwable)
        {
            string method  = MDC.Get("method");
            string path    = MDC.Get("path");
            string message = GetOneLineMessage(throwable);

            AuditLog.Warn("FAILED [{}:{}] response [{}] {}", new object[] { method, path, status
                                                                            , message });
            Log.Warn("[{}:{}] response [{}] {}", new object[] { method, path, status, message }, throwable);
        }
コード例 #4
0
        /// <summary>Creates a HTTP JAX-RPC response serializing the exception in it as JSON.
        ///     </summary>
        /// <param name="status">the error code to set in the response</param>
        /// <param name="ex">the exception to serialize in the response</param>
        /// <returns>the JAX-RPC response with the set error and JSON encoded exception</returns>
        public static Response CreateJerseyExceptionResponse(Response.Status status, Exception
                                                             ex)
        {
            IDictionary <string, object> json = new LinkedHashMap <string, object>();

            json[ErrorMessageJson]   = GetOneLineMessage(ex);
            json[ErrorExceptionJson] = ex.GetType().Name;
            json[ErrorClassnameJson] = ex.GetType().FullName;
            IDictionary <string, object> response = new LinkedHashMap <string, object>();

            response[ErrorJson] = json;
            return(Response.Status(status).Type(MediaType.ApplicationJson).Entity(response).Build
                       ());
        }
コード例 #5
0
 private Response PlainTextResponse(Response.Status status, string entityBody)
 {
     return(status(status).type(TEXT_PLAIN_TYPE).entity(entityBody).build());
 }
コード例 #6
0
 protected internal virtual Response CreateResponse(Response.Status status, Exception
                                                    ex)
 {
     return(HttpExceptionUtils.CreateJerseyExceptionResponse(status, ex));
 }
コード例 #7
0
 protected internal virtual void Log(Response.Status status, Exception throwable)
 {
     Log.Debug("{}", throwable.Message, throwable);
 }
コード例 #8
0
 private static Response CreateResponse(Response.Status status, string message)
 {
     return(Response.status(status).entity(message).build());
 }
コード例 #9
0
 public MediaTypeNotSupportedException(Response.Status status, ICollection <MediaType> supported, params MediaType[] requested) : base(CreateResponse(status, Message(supported, requested)))
 {
 }