com.linkedin.restli.server.ErrorResponseFormat Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of restli-server Show documentation
Show all versions of restli-server Show documentation
Pegasus is a framework for building robust, scalable service architectures using dynamic discovery and simple asychronous type-checked REST + JSON APIs.
package com.linkedin.restli.server;
import java.util.EnumSet;
/**
* Provides settings for how error responses are formatted.
*
* [email protected]
*/
public enum ErrorResponseFormat
{
/**
* All available error information is included in responses, including server side stack trace.
*/
FULL(EnumSet.allOf(ErrorResponsePart.class)),
/**
* Only the error message and explicitly provided error details or service error code are included in responses.
*/
MESSAGE_AND_DETAILS(EnumSet.of(ErrorResponsePart.MESSAGE, ErrorResponsePart.DETAILS)),
/**
* Only the error message.
*/
MESSAGE_ONLY(EnumSet.of(ErrorResponsePart.MESSAGE)),
/**
* Clients only get back a HTTP Status code and RestConstants.HEADER_LINKEDIN_ERROR_RESPONSE header, nothing else.
*/
MINIMAL(EnumSet.noneOf(ErrorResponsePart.class));
private static enum ErrorResponsePart
{
HEADERS,
STATUS_CODE_IN_BODY,
STACKTRACE,
MESSAGE,
SERVICE_ERROR_CODE,
DETAILS
}
private final EnumSet _errorPartsToShow;
ErrorResponseFormat(EnumSet errorPartsToShow)
{
_errorPartsToShow = errorPartsToShow;
}
public static ErrorResponseFormat defaultFormat()
{
return FULL;
}
public boolean showHeaders()
{
return _errorPartsToShow.contains(ErrorResponsePart.HEADERS);
}
public boolean showStatusCodeInBody()
{
return _errorPartsToShow.contains(ErrorResponsePart.STATUS_CODE_IN_BODY);
}
public boolean showStacktrace()
{
return _errorPartsToShow.contains(ErrorResponsePart.STACKTRACE);
}
public boolean showMessage()
{
return _errorPartsToShow.contains(ErrorResponsePart.MESSAGE);
}
public boolean showServiceErrorCode()
{
return _errorPartsToShow.contains(ErrorResponsePart.SERVICE_ERROR_CODE);
}
public boolean showDetails()
{
return _errorPartsToShow.contains(ErrorResponsePart.DETAILS);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy