threaded exception handling
Some checks failed
demo.yaml / threaded exception handling (push) Failing after 0s

This commit is contained in:
Jorijn van der Graaf 2025-11-15 19:20:33 +01:00
commit c2bb9023d4
14 changed files with 237 additions and 127 deletions

View file

@ -51,40 +51,40 @@ namespace Crafter {
pclose(pipe);
}
CompileException::CompileException(std::vector<CompileError>&& errors) : errors(std::move(errors)) {
for(CompileError error : errors) {
message += std::format("File: {}:{}\nMessage: {}\nCode: {}", error.filename, error.line, error.message, error.code);
}
};
const char* CompileException::what() const noexcept {
return message.c_str();
}
// CompileException::CompileException(std::vector<CompileError>&& errors) : errors(std::move(errors)) {
// for(CompileError error : errors) {
// message += std::format("File: {}:{}\nMessage: {}\nCode: {}", error.filename, error.line, error.message, error.code);
// }
// };
// const char* CompileException::what() const noexcept {
// return message.c_str();
// }
void RunClang(const std::string_view cmd) {
std::cout << cmd << std::endl;
std::string result = RunCommand(cmd);
std::cout << result << std::endl;
// std::vector<CompileError> errors;
std::string RunClang(const std::string_view cmd) {
// std::string result = RunCommand(cmd);
// // std::vector<CompileError> errors;
// std::regex error_regex(R"((/[^:]+\.cpp):(\d+):\d+: error: (.*)\n\s*[0-9| ]*\s*(.*))");
// std::smatch match;
// // std::regex error_regex(R"((/[^:]+\.cpp):(\d+):\d+: error: (.*)\n\s*[0-9| ]*\s*(.*))");
// // std::smatch match;
// while (std::regex_search(result, match, error_regex)) {
// CompileError error;
// error.filename = match[1].str();
// error.line = std::stoi(match[2].str());
// error.message = match[3].str();
// error.code = match[4].str();
// errors.push_back(error);
// result = match.suffix().str();
// // while (std::regex_search(result, match, error_regex)) {
// // CompileError error;
// // error.filename = match[1].str();
// // error.line = std::stoi(match[2].str());
// // error.message = match[3].str();
// // error.code = match[4].str();
// // errors.push_back(error);
// // result = match.suffix().str();
// // }
// if(result != "") {
// // if(errors.size() != 0) {
// // throw CompileException(std::move(errors));
// // } else {
// throw std::runtime_error(result);
// //}
// }
if(result != "") {
// if(errors.size() != 0) {
// throw CompileException(std::move(errors));
// } else {
throw std::runtime_error(result);
//}
}
std::cout << cmd << std::endl;
return RunCommand(cmd);
}
}