[C++][Pistache] Fix compile break, error handling (#9742)

* fix compilation break with validate function

* fix error handling in handleParsingException
bug caused all errors to be regarded as an internal server error

* generate samples
This commit is contained in:
Julian G
2021-06-15 08:42:29 +02:00
committed by GitHub
parent 3edeaeea07
commit 3fcbf17536
15 changed files with 70 additions and 33 deletions

View File

@@ -49,11 +49,13 @@ void UserApi::setupRoutes() {
std::pair<Pistache::Http::Code, std::string> UserApi::handleParsingException(const std::exception& ex) const noexcept
{
try {
throw ex;
throw;
} catch (nlohmann::detail::exception &e) {
return std::make_pair(Pistache::Http::Code::Bad_Request, e.what());
} catch (org::openapitools::server::helpers::ValidationException &e) {
return std::make_pair(Pistache::Http::Code::Bad_Request, e.what());
} catch (std::exception &e) {
return std::make_pair(Pistache::Http::Code::Internal_Server_Error, e.what())
}
}