| 326 | } |
| 327 | |
| 328 | void Report::ReportImpl::AddUserComment(const std::string& message) |
| 329 | { |
| 330 | // We only allow adding comment to exceptions now |
| 331 | if (!mDocument.HasMember("exception") || message.empty()) |
| 332 | return; |
| 333 | |
| 334 | rapidjson::Value& topException = mDocument["exception"]["values"][0]; |
| 335 | |
| 336 | if (!topException.IsObject()) |
| 337 | return; |
| 338 | |
| 339 | rapidjson::Value& mechanism = topException["mechanism"]; |
| 340 | |
| 341 | // Create a data object if it still does not exist |
| 342 | if (!mechanism.HasMember("data")) |
| 343 | { |
| 344 | mechanism.AddMember( |
| 345 | "data", rapidjson::Value(rapidjson::kObjectType), |
| 346 | mDocument.GetAllocator()); |
| 347 | } |
| 348 | |
| 349 | // Add a comment itself |
| 350 | mechanism["data"].AddMember( |
| 351 | "user_comment", |
| 352 | rapidjson::Value( |
| 353 | message.data(), message.length(), mDocument.GetAllocator()), |
| 354 | mDocument.GetAllocator()); |
| 355 | } |
| 356 | |
| 357 | |
| 358 | void Report::ReportImpl::Send(CompletionHandler completionHandler) const |