Skip to content

Commit

Permalink
fixed unclear error message (closes #224)
Browse files Browse the repository at this point in the history
  • Loading branch information
marzer committed Jul 12, 2024
1 parent 7ddb985 commit 495119a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ template:
#### Fixes

- fixed `is_homogeneous()` overloads with `first_nonmatch` outparam being broken in optimized builds (#231) (@Forbinn)
- fixed unclear error message when parsing integers that would overflow (#224) (@chrimbo)

## v3.4.0

Expand Down
14 changes: 4 additions & 10 deletions include/toml++/impl/parser.inl
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ TOML_IMPL_NAMESPACE_START
set_error_and_return_default("'"sv,
traits::full_prefix,
std::string_view{ digits, length },
"' is not representable in 64 bits"sv);
"' is not representable as a signed 64-bit integer"sv);

// do the thing
{
Expand All @@ -2267,7 +2267,7 @@ TOML_IMPL_NAMESPACE_START
set_error_and_return_default("'"sv,
traits::full_prefix,
std::string_view{ digits, length },
"' is not representable in 64 bits"sv);
"' is not representable as a signed 64-bit integer"sv);

if constexpr (traits::is_signed)
{
Expand Down Expand Up @@ -3766,16 +3766,10 @@ TOML_ANON_NAMESPACE_START
{
#if TOML_EXCEPTIONS
#define TOML_PARSE_FILE_ERROR(msg, path) \
throw parse_error{ msg, source_position{}, std::make_shared<const std::string>(std::move(path)) }
throw parse_error(msg, source_position{}, std::make_shared<const std::string>(std::move(path)))
#else
#define TOML_PARSE_FILE_ERROR(msg, path) \
return parse_result \
{ \
parse_error \
{ \
msg, source_position{}, std::make_shared<const std::string>(std::move(path)) \
} \
}
return parse_result(parse_error(msg, source_position{}, std::make_shared<const std::string>(std::move(path))))
#endif

std::string file_path_str(file_path);
Expand Down
14 changes: 4 additions & 10 deletions toml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14734,7 +14734,7 @@ TOML_IMPL_NAMESPACE_START
set_error_and_return_default("'"sv,
traits::full_prefix,
std::string_view{ digits, length },
"' is not representable in 64 bits"sv);
"' is not representable as a signed 64-bit integer"sv);

// do the thing
{
Expand All @@ -14758,7 +14758,7 @@ TOML_IMPL_NAMESPACE_START
set_error_and_return_default("'"sv,
traits::full_prefix,
std::string_view{ digits, length },
"' is not representable in 64 bits"sv);
"' is not representable as a signed 64-bit integer"sv);

if constexpr (traits::is_signed)
{
Expand Down Expand Up @@ -16251,16 +16251,10 @@ TOML_ANON_NAMESPACE_START
{
#if TOML_EXCEPTIONS
#define TOML_PARSE_FILE_ERROR(msg, path) \
throw parse_error{ msg, source_position{}, std::make_shared<const std::string>(std::move(path)) }
throw parse_error(msg, source_position{}, std::make_shared<const std::string>(std::move(path)))
#else
#define TOML_PARSE_FILE_ERROR(msg, path) \
return parse_result \
{ \
parse_error \
{ \
msg, source_position{}, std::make_shared<const std::string>(std::move(path)) \
} \
}
return parse_result(parse_error(msg, source_position{}, std::make_shared<const std::string>(std::move(path))))
#endif

std::string file_path_str(file_path);
Expand Down

0 comments on commit 495119a

Please sign in to comment.