2020-09-14 11:56:43 +00:00
|
|
|
#pragma once
|
2021-05-06 21:04:47 +00:00
|
|
|
|
2020-09-14 11:56:43 +00:00
|
|
|
#include <stdexcept>
|
|
|
|
|
2021-05-06 21:04:47 +00:00
|
|
|
|
2020-09-14 11:56:43 +00:00
|
|
|
/// Throw DB::Exception-like exception before its definition.
|
|
|
|
/// DB::Exception derived from Poco::Exception derived from std::exception.
|
2021-05-06 21:04:47 +00:00
|
|
|
/// DB::Exception generally caught as Poco::Exception. std::exception generally has other catch blocks and could lead to other outcomes.
|
2020-09-14 11:56:43 +00:00
|
|
|
/// DB::Exception is not defined yet. It'd better to throw Poco::Exception but we do not want to include any big header here, even <string>.
|
|
|
|
/// So we throw some std::exception instead in the hope its catch block is the same as DB::Exception one.
|
|
|
|
template <typename T>
|
2021-05-06 21:04:47 +00:00
|
|
|
[[noreturn]] inline void throwError(const T & err)
|
2020-09-14 11:56:43 +00:00
|
|
|
{
|
|
|
|
throw std::runtime_error(err);
|
|
|
|
}
|