MarkLogic Connect
MarkLogic Connect Client API Collection
Static Public Member Functions | List of all members
mlclient::utilities::ResponseHelper Class Reference

This class provides utility functions to ease the use of Response objects. More...

#include <ResponseHelper.hpp>

Static Public Member Functions

static MLCLIENT_API bool isInError (const Response &resp)
 Returns whether the specified response is a MarkLogic error response. More...
 
static MLCLIENT_API std::string getErrorMessage (const Response &resp)
 Returns the error message of a Response in error Throws an exception if the response is not in error. More...
 
static MLCLIENT_API std::string getErrorDetailAsString (const Response &resp)
 Returns the full error trace information as a string Throws an exception if the response is not in error. More...
 
static MLCLIENT_API std::vector< std::string > getSuggestions (const Response &resp)
 Returns a string list of suggestion values. Used with the response from POST /v1/suggest. More...
 
static MLCLIENT_API double getAggregateResult (const Response &resp, const std::string &aggName)
 Returns a double result from the specified aggregate in the result set. More...
 
static MLCLIENT_API void getAggregateResults (const Response &resp, ValuesResult &vr)
 Extracts all aggregate results and places them in the provided ValuesResult holder. More...
 
static MLCLIENT_API void getComplexAggregateResults (const Response &resp, ValuesResult &vr)
 Extracts all complex aggregate results and places them in the provided ValuesResult holder. More...
 

Detailed Description

This class provides utility functions to ease the use of Response objects.

Author
Adam Fowler adam..nosp@m.fowl.nosp@m.er@ma.nosp@m.rklo.nosp@m.gic.c.nosp@m.om
Since
8.0.2
Date
2016-06-08
Note
This class has an external dependency on Microsoft's C++ cpprest API. As this API is required to use MarkLogic's C++ wrapper (this API) , this does not introduce any extra dependencies.

Member Function Documentation

static MLCLIENT_API double mlclient::utilities::ResponseHelper::getAggregateResult ( const Response resp,
const std::string &  aggName 
)
static

Returns a double result from the specified aggregate in the result set.

Parameters
[in]respThe Response object
[in]aggNameThe aggregate name to return (a single response allows multiple to be returned)
Returns
double The double typed aggregate result
static MLCLIENT_API void mlclient::utilities::ResponseHelper::getAggregateResults ( const Response resp,
ValuesResult vr 
)
static

Extracts all aggregate results and places them in the provided ValuesResult holder.

Parameters
[in]respThe response to parse
[in,out]vrThe ValuesResult object to populate
static MLCLIENT_API void mlclient::utilities::ResponseHelper::getComplexAggregateResults ( const Response resp,
ValuesResult vr 
)
static

Extracts all complex aggregate results and places them in the provided ValuesResult holder.

Note
UDFs don't just return double values, they can return multiple values, and arrays of them (multiple map:map() objects)
Parameters
[in]respThe response to parse
[in,out]vrThe ValuesResult object to populate
static MLCLIENT_API std::string mlclient::utilities::ResponseHelper::getErrorDetailAsString ( const Response resp)
static

Returns the full error trace information as a string Throws an exception if the response is not in error.

Parameters
ResponseThe response to introspect
Returns
The full error stack as a string, if available
static MLCLIENT_API std::string mlclient::utilities::ResponseHelper::getErrorMessage ( const Response resp)
static

Returns the error message of a Response in error Throws an exception if the response is not in error.

Parameters
ResponseThe response to introspect
Returns
The string value of the top level error message, if any
static MLCLIENT_API std::vector<std::string> mlclient::utilities::ResponseHelper::getSuggestions ( const Response resp)
static

Returns a string list of suggestion values. Used with the response from POST /v1/suggest.

Returns a blank list if the response does not contain suggestions. Throws an exception if response is in error.

Parameters
ResponseThe response to introspect
Returns
A list of suggestion values
static MLCLIENT_API bool mlclient::utilities::ResponseHelper::isInError ( const Response resp)
static

Returns whether the specified response is a MarkLogic error response.

Note
Some MarkLogic error response do NOT return a HTTP 500, so this is an important method to learn!
Parameters
ResponseThe response to introspect
Returns
True if the Response is an error response

The documentation for this class was generated from the following file: