1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 04:02:42 +01:00

Simplify fmt::throw_exception

Gradual exception deprecation: disallow choosing exception type.
However, the function itself can remain here forever.
This commit is contained in:
Nekotekina 2019-11-08 00:36:59 +03:00
parent b338014639
commit 587ae17aa2
6 changed files with 11 additions and 24 deletions

View File

@ -12,7 +12,7 @@ namespace cfg
{
if (_type != type::node)
{
fmt::throw_exception<std::logic_error>("Invalid root node" HERE);
fmt::throw_exception("Invalid root node" HERE);
}
}
@ -23,7 +23,7 @@ namespace cfg
{
if (pair.first == name)
{
fmt::throw_exception<std::logic_error>("Node already exists: %s" HERE, name);
fmt::throw_exception("Node already exists: %s" HERE, name);
}
}
@ -32,12 +32,12 @@ namespace cfg
bool _base::from_string(const std::string&)
{
fmt::throw_exception<std::logic_error>("from_string() purecall" HERE);
fmt::throw_exception("from_string() purecall" HERE);
}
bool _base::from_list(std::vector<std::string>&&)
{
fmt::throw_exception<std::logic_error>("from_list() purecall" HERE);
fmt::throw_exception("from_list() purecall" HERE);
}
// Emit YAML

View File

@ -911,7 +911,7 @@ bool fs::utime(const std::string& path, s64 atime, s64 mtime)
void fs::file::xnull() const
{
fmt::throw_exception<std::logic_error>("fs::file is null");
fmt::throw_exception("fs::file is null");
}
void fs::file::xfail() const
@ -1330,7 +1330,7 @@ fs::native_handle fs::file::get_handle() const
void fs::dir::xnull() const
{
fmt::throw_exception<std::logic_error>("fs::dir is null");
fmt::throw_exception("fs::dir is null");
}
bool fs::dir::open(const std::string& path)

View File

@ -259,25 +259,13 @@ namespace fmt
throw std::range_error{out};
}
// Hidden template
template <typename T>
void raw_throw_exception(const char* fmt, const fmt_type_info* sup, const u64* args)
{
std::string out;
raw_append(out, fmt, sup, args);
throw T{out};
throw std::runtime_error{out};
}
// Explicit instantiations (not exhaustive)
template void raw_throw_exception<std::runtime_error>(const char*, const fmt_type_info*, const u64*);
template void raw_throw_exception<std::logic_error>(const char*, const fmt_type_info*, const u64*);
template void raw_throw_exception<std::domain_error>(const char*, const fmt_type_info*, const u64*);
template void raw_throw_exception<std::invalid_argument>(const char*, const fmt_type_info*, const u64*);
template void raw_throw_exception<std::out_of_range>(const char*, const fmt_type_info*, const u64*);
template void raw_throw_exception<std::range_error>(const char*, const fmt_type_info*, const u64*);
template void raw_throw_exception<std::overflow_error>(const char*, const fmt_type_info*, const u64*);
template void raw_throw_exception<std::underflow_error>(const char*, const fmt_type_info*, const u64*);
struct cfmt_src;
}

View File

@ -291,14 +291,13 @@ namespace fmt
}
// Internal exception message formatting template, must be explicitly specialized or instantiated in cpp to minimize code bloat
template <typename T>
[[noreturn]] void raw_throw_exception(const char*, const fmt_type_info*, const u64*);
// Throw exception with formatting
template <typename T = std::runtime_error, typename... Args>
template <typename... Args>
[[noreturn]] SAFE_BUFFERS FORCE_INLINE void throw_exception(const char* fmt, const Args&... args)
{
static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make<fmt_unveil_t<Args>>()...};
raw_throw_exception<T>(fmt, type_list, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
raw_throw_exception(fmt, type_list, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
}
}

View File

@ -182,7 +182,7 @@ static u64 ppu_cache(u32 addr)
const auto& table = *(
g_cfg.core.ppu_decoder == ppu_decoder_type::precise ? &g_ppu_interpreter_precise.get_table() :
g_cfg.core.ppu_decoder == ppu_decoder_type::fast ? &g_ppu_interpreter_fast.get_table() :
(fmt::throw_exception<std::logic_error>("Invalid PPU decoder"), nullptr));
(fmt::throw_exception("Invalid PPU decoder"), nullptr));
const u32 value = vm::read32(addr);
return (u64)value << 32 | ::narrow<u32>(reinterpret_cast<std::uintptr_t>(table[ppu_decode(value)]));

View File

@ -1168,7 +1168,7 @@ void spu_recompiler_base::old_interpreter(spu_thread& spu, void* ls, u8* rip) tr
const auto& table = *(
g_cfg.core.spu_decoder == spu_decoder_type::precise ? &g_spu_interpreter_precise.get_table() :
g_cfg.core.spu_decoder == spu_decoder_type::fast ? &g_spu_interpreter_fast.get_table() :
(fmt::throw_exception<std::logic_error>("Invalid SPU decoder"), nullptr));
(fmt::throw_exception("Invalid SPU decoder"), nullptr));
// LS pointer
const auto base = static_cast<const u8*>(ls);