lvl
is an enum class
.
switch(lvl)
{
case LogLevel::Trace:
return "Trace";
case LogLevel::Debug:
return "Debug";
case LogLevel::Info:
return "Info";
case LogLevel::Warning:
return "Warning";
case LogLevel::Error:
return "Error";
case LogLevel::Fatal:
return "Fatal";
default:
assert(0 && "Unhandled LogLevel in LevelToStr"); return "???"; // This one?
throw std::invalid_argument( "Unhandled LogLevel in LevelToStr" ); // or this one?
}
The consensus is the default
should be there, but the opinions in the related question are divided on what it should be doing. Crash the whole thing? Crash the current thread? Try to handle the exception gracefully?
The sides present some arguments in the comments but the discussion isn't quite conclusive.
Could someone present a comprehensive answer which one should be used, or in which conditions?