3 #include <torch/csrc/jit/script/tree.h> 11 : ss(e.ss.str()), context(e.context), the_message(e.the_message) {}
15 : context(std::make_shared<SourceRange>(r)) {}
16 explicit ErrorReport(std::shared_ptr<SourceLocation> loc)
17 : context(std::move(loc)) {}
20 const char* what()
const noexcept
override {
21 std::stringstream msg;
22 msg <<
"\n" << ss.str();
23 if (context !=
nullptr) {
25 context->highlight(msg);
29 the_message = msg.str();
30 return the_message.c_str();
37 mutable std::stringstream ss;
38 std::shared_ptr<SourceLocation> context;
39 mutable std::string the_message;
48 #define JIT_SCRIPT_ASSERT(ctx, cond) \ 50 throw ::torch::jit::script::ErrorReport(ctx) \ 51 << __FILE__ << ":" << __LINE__ << ": assertion failed: " << #cond; \