Tabnine Logo
ErrorResponse.getErrors
Code IndexAdd Tabnine to your IDE (free)

How to use
getErrors
method
in
io.sphere.sdk.models.errors.ErrorResponse

Best Java code snippets using io.sphere.sdk.models.errors.ErrorResponse.getErrors (Showing top 6 results out of 315)

origin: commercetools/commercetools-jvm-sdk

private boolean isRecoverableException(final Throwable throwable) {
  if (throwable != null) {
    final Throwable cause = throwable.getCause();
    return cause instanceof ConcurrentModificationException
        || (cause instanceof ErrorResponseException
          && ((ErrorResponse) cause).getErrors().stream().anyMatch(e -> e.getCode().equals(DuplicateFieldError.CODE)));
  }
  return true;
}
origin: commercetools/commercetools-jvm-sdk

default boolean hasErrorCode(final String errorCode) {
  return getErrors().stream().anyMatch(sphereError -> sphereError.getCode().equals(errorCode));
}
origin: commercetools/commercetools-jvm-sdk

public ErrorResponseException(final ErrorResponse errorResponse) {
  this(errorResponse.getStatusCode(), errorResponse.getMessage(), errorResponse.getErrors());
}
origin: commercetools/commercetools-jvm-sdk

public ConcurrentModificationException(final ErrorResponse errorResponse) {
  this(errorResponse.getStatusCode(), errorResponse.getMessage(), errorResponse.getErrors());
}
origin: commercetools/commercetools-jvm-sdk

  @Test
  public void notMatchingError() throws Exception {
    final String json = "{\n" +
        "  \"statusCode\" : 400,\n" +
        "  \"message\" : \"Message.\",\n" +
        "  \"errors\" : [ {\n" +
        "    \"code\" : \"OtherCode\",\n" +
        "    \"message\" : \"Message.\"" +
        "  } ]\n" +
        "}";
    final ErrorResponse sphereErrorResponse = SphereJsonUtils.readObject(json, ErrorResponse.typeReference());
    assertThatThrownBy(() -> sphereErrorResponse.getErrors().get(0).as(InvalidJsonInputError.class))
        .isInstanceOf(IllegalArgumentException.class);
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void castToConcreteError() throws Exception {
  final String json = "{\n" +
      "  \"statusCode\" : 400,\n" +
      "  \"message\" : \"Request body does not contain valid JSON.\",\n" +
      "  \"errors\" : [ {\n" +
      "    \"code\" : \"InvalidJsonInput\",\n" +
      "    \"message\" : \"Request body does not contain valid JSON.\",\n" +
      "    \"detailedErrorMessage\" : \"detailed error message\"" +
      "  } ]\n" +
      "}";
  final ErrorResponse sphereErrorResponse = SphereJsonUtils.readObject(json, ErrorResponse.typeReference());
  final InvalidJsonInputError jsonError = sphereErrorResponse.getErrors().get(0).as(InvalidJsonInputError.class);
  assertThat(jsonError.getDetailedErrorMessage()).isEqualTo("detailed error message");
}
io.sphere.sdk.models.errorsErrorResponsegetErrors

Popular methods of ErrorResponse

  • typeReference
  • getMessage
  • getStatusCode

Popular in Java

  • Reading from database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setContentView (Activity)
  • getResourceAsStream (ClassLoader)
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now