Skip to content

Commit

Permalink
Merge pull request #69 from MeanSquaredError/main
Browse files Browse the repository at this point in the history
Add a base exception for all taopq exceptions.
  • Loading branch information
d-frey authored Oct 4, 2023
2 parents 0a00b0e + 1e50ae5 commit 950c3ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions include/tao/pq/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,27 @@

namespace tao::pq
{
struct timeout_reached
struct base_error
: std::runtime_error
{
using std::runtime_error::runtime_error;
};

struct timeout_reached
: base_error
{
using base_error::base_error;
};

struct network_error
: std::runtime_error
: base_error
{
using std::runtime_error::runtime_error;
using base_error::base_error;
};

// https://www.postgresql.org/docs/current/errcodes-appendix.html
struct sql_error
: std::runtime_error
: base_error
{
std::string sqlstate;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pq/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace tao::pq
{
sql_error::sql_error( const char* what, const std::string_view in_sqlstate )
: std::runtime_error( what ),
: base_error( what ),
sqlstate( in_sqlstate )
{}

Expand Down

0 comments on commit 950c3ed

Please sign in to comment.