aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt
diff options
context:
space:
mode:
authordgolear <dgolear@yandex-team.com>2024-03-12 01:00:49 +0300
committerdgolear <dgolear@yandex-team.com>2024-03-12 01:10:51 +0300
commit397a915fb597f46120a368c922143962f305f17a (patch)
tree1d1bbde0f434a77f4a13cccfa6f850f11c5c8d7a /library/cpp/yt
parent767dfbd8f2e59e28ba40727a8c858600ce3d83ea (diff)
downloadydb-397a915fb597f46120a368c922143962f305f17a.tar.gz
YTORM-275: Fix TInstant deserialization from microsecond values
47845f7aede6898d43680bd7c6f1d48c05607e34
Diffstat (limited to 'library/cpp/yt')
-rw-r--r--library/cpp/yt/misc/cast-inl.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/library/cpp/yt/misc/cast-inl.h b/library/cpp/yt/misc/cast-inl.h
index ceacda91bd..59be41ac1c 100644
--- a/library/cpp/yt/misc/cast-inl.h
+++ b/library/cpp/yt/misc/cast-inl.h
@@ -9,7 +9,6 @@
#include <util/string/cast.h>
#include <util/string/printf.h>
-#include <concepts>
#include <type_traits>
namespace NYT {
@@ -78,6 +77,8 @@ inline TString FormatInvalidCastValue(char8_t value)
} // namespace NDetail
+////////////////////////////////////////////////////////////////////////////////
+
template <class T, class S>
bool TryIntegralCast(S value, T* result)
{
@@ -93,8 +94,12 @@ T CheckedIntegralCast(S value)
{
T result;
if (!TryIntegralCast<T>(value, &result)) {
- throw TSimpleException(Sprintf("Argument value %s is out of expected range",
- NYT::NDetail::FormatInvalidCastValue(value).c_str()));
+ throw TSimpleException(Sprintf("Error casting %s value \"%s\" to %s: value is out of expected range [%s; %s]",
+ TypeName<S>().c_str(),
+ NYT::NDetail::FormatInvalidCastValue(value).c_str(),
+ TypeName<T>().c_str(),
+ ::ToString(std::numeric_limits<T>::min()).c_str(),
+ ::ToString(std::numeric_limits<T>::max()).c_str()));
}
return result;
}
@@ -119,7 +124,8 @@ T CheckedEnumCast(S value)
{
T result;
if (!TryEnumCast<T>(value, &result)) {
- throw TSimpleException(Sprintf("Invalid value %d of enum type %s",
+ throw TSimpleException(Sprintf("Error casting %s value \"%d\" to enum %s",
+ TypeName<S>().c_str(),
static_cast<int>(value),
TEnumTraits<T>::GetTypeName().data()));
}