Add support for multiple runtime error messages
Storing all the runtime errors makes it possible to return all of them them via the REST API. MaxAdmin will still only show the latest error but MaxCtrl will now show all errors if more than one error occurs.
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
* Public License.
|
||||
*/
|
||||
|
||||
#include <maxscale/json_api.h>
|
||||
#include <maxscale/json_api.hh>
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -207,6 +207,24 @@ json_t* mxs_json_error(const char* format, ...)
|
||||
return json_error(message);
|
||||
}
|
||||
|
||||
json_t* mxs_json_error(const std::vector<std::string>& errors)
|
||||
{
|
||||
json_t* rval = nullptr;
|
||||
|
||||
if (!errors.empty())
|
||||
{
|
||||
auto it = errors.begin();
|
||||
rval = json_error(it->c_str());
|
||||
|
||||
for (it = std::next(it); it != errors.end(); ++it)
|
||||
{
|
||||
rval = mxs_json_error_append(rval, it->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
static json_t* json_error_append(json_t* obj, const char* message)
|
||||
{
|
||||
json_t* err = json_error_detail(message);
|
||||
|
||||
Reference in New Issue
Block a user