mirror of
https://github.com/Icinga/icinga2.git
synced 2026-06-13 18:50:22 -04:00
Guard against assert() failures in SendJsonError()
Co-authored-by: Julian Brost <julian.brost@icinga.com>
This commit is contained in:
parent
6a3979fd1f
commit
fe469a5455
1 changed files with 10 additions and 0 deletions
|
|
@ -86,6 +86,16 @@ void HttpUtility::SendJsonBody(HttpApiResponse& response, const Dictionary::Ptr&
|
|||
void HttpUtility::SendJsonError(HttpApiResponse& response,
|
||||
const Dictionary::Ptr& params, int code, const String& info, const String& diagnosticInformation)
|
||||
{
|
||||
if (response.HasSerializationStarted()) {
|
||||
std::ostringstream err;
|
||||
err << "Impossible to send error response after streaming has started: error: '" << code << "', status: '"
|
||||
<< info << "'";
|
||||
if (!diagnosticInformation.IsEmpty()) {
|
||||
err << ", diagnostic_information: '" << diagnosticInformation << "'";
|
||||
}
|
||||
BOOST_THROW_EXCEPTION(std::logic_error{err.str()});
|
||||
}
|
||||
|
||||
Dictionary::Ptr result = new Dictionary({ { "error", code } });
|
||||
|
||||
if (!info.IsEmpty()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue