Don't throw if not connected

This commit is contained in:
Yves
2025-02-21 10:14:41 +01:00
parent c7a84307c2
commit 86d061a605

View File

@@ -316,6 +316,14 @@ void HttpServer::HandleGetLocalToken(const httplib::Request &req,
Connection connection(*db);
auto query_res = connection.Query("CALL get_md_token()");
if (query_res->HasError()) {
if (StringUtil::Contains(
query_res->GetError(),
"GET_MD_TOKEN will be available after you connect")) {
// UI expects an empty response if MD isn't connected
res.set_content("", "text/plain");
return;
}
res.status = 500;
res.set_content("Could not get token: " + query_res->GetError(),
"text/plain");