< . . . codes . . . >
conn = PQconnectdb("dbname=dbname user=postgres password=postgres host=127.0.0.1 port=5432");
< . . . codes . . . >
I want to create a somewhat catch C++ code that catch if the connection fail and pops-up the fail error and not close the IDE or not crash it.You can simply use C++ try catch statement in your plugin source.
your_plugin_event_handler_function()
{
try
{
connect to your database
}
catch (error)
{
show a message box
}
}
catch (error)because id tried something like this
{
show a message box
}
}
if(PQstatus(conn) != CONNECTION_OK) {it print the error in the IDE console and crash the IDE with an error something like "Aborted (core dumped)".
Manager::Get()->GetLogManager()->Log(_("Database connection failed!"));
}