Skip to content

Commit

Permalink
Added additional exception handler to also show unknown exceptions in…
Browse files Browse the repository at this point in the history
… live data api endpoint
  • Loading branch information
tbnobody committed Jun 8, 2023
1 parent 593a330 commit 721f82a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/WebApi_ws_live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ void WebApiWsLiveClass::loop()
_ws.textAll(buffer);
}

} catch (std::bad_alloc& bad_alloc) {
} catch (const std::bad_alloc& bad_alloc) {
MessageOutput.printf("Call to /api/livedata/status temporarely out of resources. Reason: \"%s\".\r\n", bad_alloc.what());
} catch (const std::exception& exc) {
MessageOutput.printf("Unknown exception in /api/livedata/status. Reason: \"%s\".\r\n", exc.what());
}

_lastWsPublish = millis();
Expand Down Expand Up @@ -229,9 +231,11 @@ void WebApiWsLiveClass::onLivedataStatus(AsyncWebServerRequest* request)
response->setLength();
request->send(response);

} catch (std::bad_alloc& bad_alloc) {
} catch (const std::bad_alloc& bad_alloc) {
MessageOutput.printf("Call to /api/livedata/status temporarely out of resources. Reason: \"%s\".\r\n", bad_alloc.what());

WebApi.sendTooManyRequests(request);
} catch (const std::exception& exc) {
MessageOutput.printf("Unknown exception in /api/livedata/status. Reason: \"%s\".\r\n", exc.what());
WebApi.sendTooManyRequests(request);
}
}

0 comments on commit 721f82a

Please sign in to comment.