debug/panic: use fmt for unhandled messages

This commit is contained in:
Danny Robson 2021-04-13 15:18:37 +10:00
parent 986e7d18d8
commit 4848178cc7
4 changed files with 10 additions and 8 deletions

View File

@ -10,7 +10,7 @@ include (search_libs)
find_package (PythonInterp 3 REQUIRED) find_package (PythonInterp 3 REQUIRED)
find_package (RAGEL 6.9 REQUIRED) find_package (RAGEL 6.9 REQUIRED)
find_package (fmt REQUIRED)
if (WIN32) if (WIN32)
# Enable features for Windows Vista and higher # Enable features for Windows Vista and higher
@ -38,7 +38,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
############################################################################### ###############################################################################
add_library(cruft) add_library(cruft)
target_link_libraries(cruft ${NC_CXX_STDCXXFS}) target_link_libraries(cruft ${NC_CXX_STDCXXFS} fmt::fmt)
# Setup a directory to hold built sources we may need to export to clients. # Setup a directory to hold built sources we may need to export to clients.

View File

@ -8,8 +8,9 @@
#pragma once #pragma once
#include <fmt/format.h>
#include <type_traits> #include <type_traits>
#include <sstream>
#include <utility> #include <utility>
@ -127,9 +128,7 @@ namespace cruft::debug::detail {
if constexpr (std::is_enum_v<base_type>) { if constexpr (std::is_enum_v<base_type>) {
unhandled (static_cast<std::underlying_type_t<base_type>> (t)); unhandled (static_cast<std::underlying_type_t<base_type>> (t));
} else { } else {
std::ostringstream os; ::panic (fmt::format ("unhandled value: {}", t));
os << "unhandled value: " << t << '\n';
::panic (os.str ());
} }
} }
} }

View File

@ -13,6 +13,8 @@
#include "vector.hpp" #include "vector.hpp"
#include "coord/ops.hpp" #include "coord/ops.hpp"
#include <ostream>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
using cruft::quaternion; using cruft::quaternion;

View File

@ -8,12 +8,13 @@
#include "version.hpp" #include "version.hpp"
#include "maths.hpp" #include "maths.hpp"
#include "debug/assert.hpp"
#include "debug/panic.hpp" #include "debug/panic.hpp"
#include <cstring>
#include <stdexcept> #include <stdexcept>
#include <ostream>
#include "debug/assert.hpp" #include <cstring>
// We generate some really old style C code via ragel here, so we have to // We generate some really old style C code via ragel here, so we have to
// disable some noisy warnings (doubly so given -Werror) // disable some noisy warnings (doubly so given -Werror)