pytorch/torch/csrc/jit/runtime/jit_exception.cpp
Richard Barnes ed327876f5 [codemod] c10:optional -> std::optional (#126135)
Generated by running the following from PyTorch root:
```
find . -regex ".*\.\(cpp\|h\|cu\|hpp\|cc\|cxx\)$" | grep -v "build/" | xargs -n 50 -P 4 perl -pi -e 's/c10::optional/std::optional/'
```

`c10::optional` is just an alias for `std::optional`. This removes usages of that alias in preparation for eliminating it entirely.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/126135
Approved by: https://github.com/Skylion007, https://github.com/malfet, https://github.com/albanD, https://github.com/aaronenyeshi
2024-05-14 19:35:51 +00:00

31 lines
917 B
C++

#include <torch/csrc/jit/runtime/jit_exception.h>
namespace torch::jit {
static thread_local std::string caughtOriginalMsg = "";
static thread_local std::string caughtPythonClassName = "";
JITException::JITException(
const std::string& msg,
std::optional<std::string> python_class_name,
std::optional<std::string> original_msg)
: std::runtime_error(msg),
python_class_name_(std::move(python_class_name)),
original_msg_(std::move(original_msg)) {}
const std::string& JITException::getCaughtOriginalMsg() {
return caughtOriginalMsg;
}
const std::string& JITException::getCaughtPythonClassName() {
return caughtPythonClassName;
}
void JITException::setCaughtOriginalMsg(const std::string& msg) {
caughtOriginalMsg = msg;
}
void JITException::setCaughtPythonClassName(
const std::string& pythonClassName) {
caughtPythonClassName = pythonClassName;
}
} // namespace torch::jit