Skip to content

throwing exception with "complex" message #534

@Dharmesh946

Description

@Dharmesh946

C++Weekly

exceptions

how to do something like:

try
{
   something_that_may_throw(args…);
}
catch(const std::exception& e)
{
   throw std::runtime_error(some string built on the fly);
}

How to "build" the message (that may depend on runtime information) without having the build himself throwing?

Idea: using std::snstring but complicated with std::string_view which are not null-terminated (std::copy perhaps?).

Length

5-10 minutes

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions