| 184 | class AggregateException : public std::exception { |
| 185 | public: |
| 186 | explicit AggregateException(std::vector<std::exception_ptr> excs) |
| 187 | // NOLINTNEXTLINE(bugprone-throw-keyword-missing) |
| 188 | : exceptions_(std::move(excs)) { |
| 189 | message_ = |
| 190 | std::to_string(exceptions_.size()) + " task(s) threw exception(s):\n"; |
| 191 | for (size_t i = 0; i < exceptions_.size(); ++i) { |
| 192 | try { |
| 193 | std::rethrow_exception(exceptions_[i]); |
| 194 | } catch (const std::exception& e) { |
| 195 | message_ += e.what(); |
| 196 | } catch (...) { |
| 197 | message_ += "Unknown exception"; |
| 198 | } |
| 199 | if (i + 1 < exceptions_.size()) { |
| 200 | message_ += "\n"; |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | const char* what() const noexcept override { return message_.c_str(); } |
| 206 | |