Skip to content

Commit

Permalink
fix control may reach end warning for VFatal (#1222)
Browse files Browse the repository at this point in the history
  • Loading branch information
yxlao authored and syncle committed Oct 8, 2019
1 parent 1c9118d commit 09a3441
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
25 changes: 11 additions & 14 deletions src/Open3D/Utility/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ namespace open3d {
namespace utility {

enum class VerbosityLevel {
Off = 0,
Fatal = 1,
Error = 2,
Warning = 3,
Info = 4,
Debug = 5,
Fatal = 0,
Error = 1,
Warning = 2,
Info = 3,
Debug = 4,
};

class Logger {
Expand All @@ -72,13 +71,11 @@ class Logger {
return instance;
}

void VFatal(const char *format, fmt::format_args args) const {
if (verbosity_level_ >= VerbosityLevel::Fatal) {
std::string err_msg = fmt::vformat(format, args);
err_msg = fmt::format("[Open3D FATAL] {}", err_msg);
err_msg = ColorString(err_msg, TextColor::Red, 1);
throw std::runtime_error(err_msg);
}
void VFatal[[noreturn]](const char *format, fmt::format_args args) const {
std::string err_msg = fmt::vformat(format, args);
err_msg = fmt::format("[Open3D FATAL] {}", err_msg);
err_msg = ColorString(err_msg, TextColor::Red, 1);
throw std::runtime_error(err_msg);
}

void VError(const char *format, fmt::format_args args) const {
Expand Down Expand Up @@ -209,7 +206,7 @@ inline VerbosityLevel GetVerbosityLevel() {
}

template <typename... Args>
inline void LogFatal(const char *format, const Args &... args) {
inline void LogFatal[[noreturn]](const char *format, const Args &... args) {
Logger::i().VFatal(format, fmt::make_format_args(args...));
}

Expand Down
3 changes: 1 addition & 2 deletions src/Python/utility/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ using namespace open3d;
void pybind_console(py::module &m) {
py::enum_<utility::VerbosityLevel> vl(m, "VerbosityLevel", py::arithmetic(),
"VerbosityLevel");
vl.value("Off", utility::VerbosityLevel::Off)
.value("Fatal", utility::VerbosityLevel::Fatal)
vl.value("Fatal", utility::VerbosityLevel::Fatal)
.value("Error", utility::VerbosityLevel::Error)
.value("Warning", utility::VerbosityLevel::Warning)
.value("Info", utility::VerbosityLevel::Info)
Expand Down

0 comments on commit 09a3441

Please sign in to comment.