Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Pass std::source_location into libpqxx functions. #947

Open
wants to merge 18 commits into
base: start-8
Choose a base branch
from

Conversation

jtv
Copy link
Owner

@jtv jtv commented Jan 30, 2025

I'm trying to add std::source_location parameters to every libpqxx function that may throw, and pass the value on whenever those functions call other libpqxx functions that may throw. The ideal end state would be one where every exception coming out of libpqxx would convey the location of the original call into libpqxx that ultimately triggered the exception.

In practice this ideal does not look fully attainable, because as far as I can see...

  1. there's no way to add a parameter with a default value to the end of a template function with a variable number of parameters.
  2. we have no reasonable way of dealing with exceptions that the standard library may throw when we call it.
  3. destructors and overloaded operators don't generally let you add parameters.

@jtv jtv changed the title Pass std::source_location into libpqxx functions. WIP: Pass std::source_location into libpqxx functions. Jan 30, 2025
This is just one small portion of the work needed.  I'm trying to ensure
that every libpqxx function that may throw an exception has a
`source_location` parameter, and that it passes this to any functions
it calls that may throw.

The end result would ideally be that any exception thrown by libpqxx
would include the location of the original call into libpqxx.

In practice unfortunately I'm not so sure that I can attain this
ideal.  Type parameter packs make it difficult.
@jtv jtv force-pushed the source_location branch from 9a4f4af to 7c72352 Compare January 30, 2025 15:54
jtv added 17 commits January 30, 2025 17:39
Previous commit did the same for `array`.
Went through the `connection` header & source file to pass source
locations.  I'm sure I missed a few spots, and of course the change
leaked into many other modules.
There's a lot of places where I could not do this yet because of
templating.  Frankly I feel like the whole `std::source_location` is
waiting for a do-over.

But it's hard to imagine how it should work...  Maybe by having some
way to retrieve the call site from _within_ the callee.  That would
eliminate the gruesome parameter-passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant