Closed mattfbacon closed 3 years ago
It's on my TODO list, but first I need to finish those iterator/container requirements I'm currently working on.
Alright, no problem. BTW, for now I'm doing something like this:
} catch (std::runtime_error const& e) {
if (strstr(e.what(), "duplicate key value violates unique constraint")) {
// constraint exception
// ...
} else {
throw;
}
}
Not sure if there's a better way to get the error message from the library, but this could be an option if not.
I've given up on the iterator-stuff for today and I used the waiting time to Inspiration4's launch to implement the basic exception hierarchy similar to libpqxx. Actually, I mostly followed @jtv's lead - Jeroen, I hope you don't mind :)
Hi @d-frey, long time no see. No I don't mind. :-)
I might have gone a little overboard, but I added exception classes for all the PostgreSQL Error Codes that are documented.
In their infinite wisdom, the PostgreSQL developers documented four condition names that are ambiguous. 🤬
I turned those into templates and you need to add the error class as a template parameter, so instead of the ambiguous string_data_right_truncation
you need to specify which one you mean: string_data_right_truncation<warning>
or string_data_right_truncation<data_exception>
.
Awesome work!
Currently you just get a runtime error. Compare this to the exceptions provided by libpqxx: https://libpqxx.readthedocs.io/en/7.6.0/a00247.html.
I will try to do this myself, but I don't know much about PostgreSQL so it may be difficult.