| 71 | } |
| 72 | |
| 73 | void CrashWriter::sendError(Type type, int sig_or_error, std::string_view error_message, const FramePointers & frame_pointers, size_t offset, size_t size) |
| 74 | { |
| 75 | if (!instance) |
| 76 | { |
| 77 | LOG_INFO(logger, "Not sending crash report"); |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | try |
| 82 | { |
| 83 | LOG_INFO(logger, "Sending crash report"); |
| 84 | |
| 85 | auto out = BuilderWriteBufferFromHTTP(Poco::URI{endpoint}) |
| 86 | .withBufferSize(4096).withConnectionGroup(HTTPConnectionGroupType::HTTP).create(); |
| 87 | auto & json = *out; |
| 88 | |
| 89 | FormatSettings settings; |
| 90 | |
| 91 | writeChar('{', json); |
| 92 | writeCString("\"message\":", json); |
| 93 | writeJSONString(error_message, json, settings); |
| 94 | |
| 95 | switch (type) |
| 96 | { |
| 97 | case SIGNAL: |
| 98 | { |
| 99 | writeCString(",\"type\":\"signal\"", json); |
| 100 | writeCString(",\"signal_number\":", json); |
| 101 | writeIntText(sig_or_error, json); |
| 102 | break; |
| 103 | } |
| 104 | case EXCEPTION: |
| 105 | { |
| 106 | writeCString(",\"type\":\"exception\"", json); |
| 107 | writeCString(",\"exception_code\":", json); |
| 108 | writeIntText(sig_or_error, json); |
| 109 | writeCString(",\"exception_message\":", json); |
| 110 | writeJSONString(ErrorCodes::getName(sig_or_error), json, settings); |
| 111 | break; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | #if (defined(__ELF__) && !defined(OS_FREEBSD)) || defined(OS_DARWIN) |
| 116 | const String & build_id_hex = SymbolIndex::instance().getBuildIDHex(); |
| 117 | writeCString(",\"build_id\":", json); |
| 118 | writeJSONString(build_id_hex, json, settings); |
| 119 | #endif |
| 120 | |
| 121 | UUID server_uuid = ServerUUID::get(); |
| 122 | if (server_uuid != UUIDHelpers::Nil) |
| 123 | { |
| 124 | std::string server_uuid_str = toString(server_uuid); |
| 125 | writeCString(",\"server_uuid\":", json); |
| 126 | writeJSONString(server_uuid_str, json, settings); |
| 127 | } |
| 128 | |
| 129 | writeCString(",\"version\":", json); |
| 130 | writeJSONString(VERSION_STRING, json, settings); |
no test coverage detected