Example usage for org.springframework.restdocs.payload PayloadHandlingException PayloadHandlingException

List of usage examples for org.springframework.restdocs.payload PayloadHandlingException PayloadHandlingException

Introduction

In this page you can find the example usage for org.springframework.restdocs.payload PayloadHandlingException PayloadHandlingException.

Prototype

PayloadHandlingException(Throwable cause) 

Source Link

Document

Creates a new PayloadHandlingException with the given cause .

Usage

From source file:org.springframework.restdocs.payload.JsonContentHandler.java

@Override
public String getUndocumentedContent(List<FieldDescriptor> fieldDescriptors) {
    Object content = readContent();
    for (FieldDescriptor fieldDescriptor : fieldDescriptors) {
        JsonFieldPath path = JsonFieldPath.compile(fieldDescriptor.getPath());
        this.fieldProcessor.remove(path, content);
    }//w ww.  j a v a 2  s .  c om
    if (!isEmpty(content)) {
        try {
            return this.objectMapper.writeValueAsString(content);
        } catch (JsonProcessingException ex) {
            throw new PayloadHandlingException(ex);
        }
    }
    return null;
}

From source file:org.springframework.restdocs.payload.JsonContentHandler.java

private Object readContent() {
    try {/*from   w ww .  ja  va 2 s .c o  m*/
        return new ObjectMapper().readValue(this.rawContent, Object.class);
    } catch (IOException ex) {
        throw new PayloadHandlingException(ex);
    }
}