Skip to content

Commit

Permalink
Merge pull request #5 from maiadegraaf/connect_exception
Browse files Browse the repository at this point in the history
Catch Exception When Opening an Already Connected Database
  • Loading branch information
maiadegraaf authored Jun 3, 2024
2 parents 688b5f8 + 8dafd30 commit 5168877
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/connect/connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,13 @@ SQLRETURN Connect::SetConnection() {
config.SetOptionsByName(config_map);

bool cache_instance = database != IN_MEMORY_PATH;
dbc->env->db = instance_cache.GetOrCreateInstance(database, config, cache_instance);

try {
dbc->env->db = instance_cache.GetOrCreateInstance(database, config, cache_instance);
} catch (std::exception &ex) {
ErrorData error(ex);
return SetDiagnosticRecord(dbc, SQL_ERROR, "SQLDriverConnect", error.Message(), SQLStateType::ST_IM003, "");
}

if (!dbc->conn) {
dbc->conn = make_uniq<Connection>(*dbc->env->db);
Expand Down

0 comments on commit 5168877

Please sign in to comment.