Search in sources :

Example 1 with DefaultError

use of com.okta.sdk.impl.error.DefaultError in project okta-sdk-java by okta.

the class DefaultDataStore method execute.

private Response execute(Request request) throws ResourceException {
    applyDefaultRequestHeaders(request);
    Response response = this.requestExecutor.executeRequest(request);
    log.trace("Executed HTTP request.");
    if (requestLog.isTraceEnabled()) {
        requestLog.trace("Executing request: method: '{}', url: {}", request.getMethod(), request.getResourceUrl());
    }
    if (response.isError()) {
        Map<String, Object> body = getBody(response);
        String requestId = response.getHeaders().getOktaRequestId();
        if (Strings.hasText(requestId)) {
            body.put(DefaultError.ERROR_ID.getName(), requestId);
        }
        throw new ResourceException(new DefaultError(body).setHeaders(response.getHeaders().getXHeaders()).setStatus(response.getHttpStatus()));
    }
    return response;
}
Also used : Response(com.okta.sdk.impl.http.Response) ResourceException(com.okta.sdk.resource.ResourceException) QueryString(com.okta.sdk.impl.http.QueryString) DefaultError(com.okta.sdk.impl.error.DefaultError)

Aggregations

DefaultError (com.okta.sdk.impl.error.DefaultError)1 QueryString (com.okta.sdk.impl.http.QueryString)1 Response (com.okta.sdk.impl.http.Response)1 ResourceException (com.okta.sdk.resource.ResourceException)1