forked from loafle/openapi-generator-original
Separate exception types (#2930)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
@@ -47,10 +47,14 @@ void StoreApi::delete_order_handler(const Pistache::Rest::Request &request, Pist
|
||||
|
||||
try {
|
||||
this->delete_order(orderId, response);
|
||||
} catch (std::runtime_error & e) {
|
||||
//send a 400 error
|
||||
response.send(Pistache::Http::Code::Bad_Request, e.what());
|
||||
return;
|
||||
} catch (nlohmann::detail::exception &e) {
|
||||
//send a 400 error
|
||||
response.send(Pistache::Http::Code::Bad_Request, e.what());
|
||||
return;
|
||||
} catch (std::runtime_error &e) {
|
||||
//send a 500 error
|
||||
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,10 +62,14 @@ void StoreApi::get_inventory_handler(const Pistache::Rest::Request &request, Pis
|
||||
|
||||
try {
|
||||
this->get_inventory(response);
|
||||
} catch (std::runtime_error & e) {
|
||||
//send a 400 error
|
||||
response.send(Pistache::Http::Code::Bad_Request, e.what());
|
||||
return;
|
||||
} catch (nlohmann::detail::exception &e) {
|
||||
//send a 400 error
|
||||
response.send(Pistache::Http::Code::Bad_Request, e.what());
|
||||
return;
|
||||
} catch (std::runtime_error &e) {
|
||||
//send a 500 error
|
||||
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -71,10 +79,14 @@ void StoreApi::get_order_by_id_handler(const Pistache::Rest::Request &request, P
|
||||
|
||||
try {
|
||||
this->get_order_by_id(orderId, response);
|
||||
} catch (std::runtime_error & e) {
|
||||
//send a 400 error
|
||||
response.send(Pistache::Http::Code::Bad_Request, e.what());
|
||||
return;
|
||||
} catch (nlohmann::detail::exception &e) {
|
||||
//send a 400 error
|
||||
response.send(Pistache::Http::Code::Bad_Request, e.what());
|
||||
return;
|
||||
} catch (std::runtime_error &e) {
|
||||
//send a 500 error
|
||||
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,10 +99,14 @@ void StoreApi::place_order_handler(const Pistache::Rest::Request &request, Pista
|
||||
try {
|
||||
nlohmann::json::parse(request.body()).get_to(body);
|
||||
this->place_order(body, response);
|
||||
} catch (std::runtime_error & e) {
|
||||
//send a 400 error
|
||||
response.send(Pistache::Http::Code::Bad_Request, e.what());
|
||||
return;
|
||||
} catch (nlohmann::detail::exception &e) {
|
||||
//send a 400 error
|
||||
response.send(Pistache::Http::Code::Bad_Request, e.what());
|
||||
return;
|
||||
} catch (std::runtime_error &e) {
|
||||
//send a 500 error
|
||||
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user