boostorg / boostorg/json

Document getting source_locations

Open
#1,065 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
479
Forks
110
Avg merge
10d 3h
Merged PRs (30d)
5

Description

I was struggling a bit getting reasonable error codes. I use the exception-based API for readability purposes. Most of these functions take a source_location parameter but it turns out that the location information is lost when the exception is thrown. For example a call to `at()` on a `json::object` will drop the information and instead have the call site of the internal function:
```
value const&
object::
at(string_view key, source_location const& loc) const&
{
return try_at(key).value(loc);
}
```
`try_at` gets called and throws so `loc` being set in the result type doesn't matter.
Is there a decent way to avoid this short of wrapping everything?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.