Caffe2 - C++ API
A deep learning, cross platform ML framework
worker_exception.h
1 #pragma once
2 
3 #include <exception>
4 #include <string>
5 #include <utility>
6 
7 namespace torch {
8 namespace data {
9 
13 struct WorkerException : public std::exception {
15  explicit WorkerException(std::exception_ptr original)
16  : original_exception(std::move(original)),
17  message("Caught exception in DataLoader worker thread.") {
18  try {
19  std::rethrow_exception(original_exception);
20  } catch (std::exception& e) {
21  message += " Original message: ";
22  message += e.what();
23  }
24  }
25 
26  const char* what() const noexcept override {
27  return message.c_str();
28  }
29 
31  std::exception_ptr original_exception;
32 
34  std::string message;
35 };
36 
37 } // namespace data
38 } // namespace torch
std::string message
This exception&#39;s message (not the original exception&#39;s message).
Definition: jit_type.h:17
An exception thrown when a DataLoader&#39;s worker thread throws an exception, which is caught...
std::exception_ptr original_exception
The original exception thrown in the worker thread.
WorkerException(std::exception_ptr original)
Constructs a WorkerException from an exception_ptr.