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()); }
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); }
/// <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); }
/// <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 ()); }
private Response PlainTextResponse(Response.Status status, string entityBody) { return(status(status).type(TEXT_PLAIN_TYPE).entity(entityBody).build()); }
protected internal virtual Response CreateResponse(Response.Status status, Exception ex) { return(HttpExceptionUtils.CreateJerseyExceptionResponse(status, ex)); }
protected internal virtual void Log(Response.Status status, Exception throwable) { Log.Debug("{}", throwable.Message, throwable); }
private static Response CreateResponse(Response.Status status, string message) { return(Response.status(status).entity(message).build()); }
public MediaTypeNotSupportedException(Response.Status status, ICollection <MediaType> supported, params MediaType[] requested) : base(CreateResponse(status, Message(supported, requested))) { }