improve warnings (#770)

This commit is contained in:
water111
2021-08-18 20:19:01 -04:00
committed by GitHub
parent 1214471fe7
commit e4f5e8eebd
3 changed files with 82 additions and 70 deletions
+8
View File
@@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <vector>
#include <stdexcept>
#include "common/util/assert.h"
#include "third-party/fmt/core.h"
@@ -15,6 +16,13 @@ class DecompWarnings {
warning(Warning::Kind::GENERAL, str, std::forward<Args>(args)...);
}
template <typename... Args>
void warn_and_throw(const std::string& str, Args&&... args) {
auto text = fmt::format(str, std::forward<Args>(args)...);
warning(Warning::Kind::GENERAL, text);
throw std::runtime_error(text);
}
template <typename... Args>
void expression_build_warning(const std::string& str, Args&&... args) {
warning(Warning::Kind::EXPR_BUILD_FAILED, str, std::forward<Args>(args)...);