2
2
* OpenAPI Petstore
3
3
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
4
4
*
5
- * OpenAPI spec version: 1.0.0
5
+ * The version of the OpenAPI document : 1.0.0
6
6
*
7
7
*
8
8
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -54,10 +54,14 @@ void PetApi::add_pet_handler(const Pistache::Rest::Request &request, Pistache::H
54
54
try {
55
55
nlohmann::json::parse (request.body ()).get_to (body);
56
56
this ->add_pet (body, response);
57
- } catch (std::runtime_error & e) {
58
- // send a 400 error
59
- response.send (Pistache::Http::Code::Bad_Request, e.what ());
60
- return ;
57
+ } catch (nlohmann::detail::exception &e) {
58
+ // send a 400 error
59
+ response.send (Pistache::Http::Code::Bad_Request, e.what ());
60
+ return ;
61
+ } catch (std::runtime_error &e) {
62
+ // send a 500 error
63
+ response.send (Pistache::Http::Code::Internal_Server_Error, e.what ());
64
+ return ;
61
65
}
62
66
63
67
}
@@ -70,10 +74,14 @@ void PetApi::delete_pet_handler(const Pistache::Rest::Request &request, Pistache
70
74
71
75
try {
72
76
this ->delete_pet (petId, apiKey, response);
73
- } catch (std::runtime_error & e) {
74
- // send a 400 error
75
- response.send (Pistache::Http::Code::Bad_Request, e.what ());
76
- return ;
77
+ } catch (nlohmann::detail::exception &e) {
78
+ // send a 400 error
79
+ response.send (Pistache::Http::Code::Bad_Request, e.what ());
80
+ return ;
81
+ } catch (std::runtime_error &e) {
82
+ // send a 500 error
83
+ response.send (Pistache::Http::Code::Internal_Server_Error, e.what ());
84
+ return ;
77
85
}
78
86
79
87
}
@@ -91,10 +99,14 @@ void PetApi::find_pets_by_status_handler(const Pistache::Rest::Request &request,
91
99
92
100
try {
93
101
this ->find_pets_by_status (status, response);
94
- } catch (std::runtime_error & e) {
95
- // send a 400 error
96
- response.send (Pistache::Http::Code::Bad_Request, e.what ());
97
- return ;
102
+ } catch (nlohmann::detail::exception &e) {
103
+ // send a 400 error
104
+ response.send (Pistache::Http::Code::Bad_Request, e.what ());
105
+ return ;
106
+ } catch (std::runtime_error &e) {
107
+ // send a 500 error
108
+ response.send (Pistache::Http::Code::Internal_Server_Error, e.what ());
109
+ return ;
98
110
}
99
111
100
112
}
@@ -112,10 +124,14 @@ void PetApi::find_pets_by_tags_handler(const Pistache::Rest::Request &request, P
112
124
113
125
try {
114
126
this ->find_pets_by_tags (tags, response);
115
- } catch (std::runtime_error & e) {
116
- // send a 400 error
117
- response.send (Pistache::Http::Code::Bad_Request, e.what ());
118
- return ;
127
+ } catch (nlohmann::detail::exception &e) {
128
+ // send a 400 error
129
+ response.send (Pistache::Http::Code::Bad_Request, e.what ());
130
+ return ;
131
+ } catch (std::runtime_error &e) {
132
+ // send a 500 error
133
+ response.send (Pistache::Http::Code::Internal_Server_Error, e.what ());
134
+ return ;
119
135
}
120
136
121
137
}
@@ -125,10 +141,14 @@ void PetApi::get_pet_by_id_handler(const Pistache::Rest::Request &request, Pista
125
141
126
142
try {
127
143
this ->get_pet_by_id (petId, response);
128
- } catch (std::runtime_error & e) {
129
- // send a 400 error
130
- response.send (Pistache::Http::Code::Bad_Request, e.what ());
131
- return ;
144
+ } catch (nlohmann::detail::exception &e) {
145
+ // send a 400 error
146
+ response.send (Pistache::Http::Code::Bad_Request, e.what ());
147
+ return ;
148
+ } catch (std::runtime_error &e) {
149
+ // send a 500 error
150
+ response.send (Pistache::Http::Code::Internal_Server_Error, e.what ());
151
+ return ;
132
152
}
133
153
134
154
}
@@ -141,30 +161,42 @@ void PetApi::update_pet_handler(const Pistache::Rest::Request &request, Pistache
141
161
try {
142
162
nlohmann::json::parse (request.body ()).get_to (body);
143
163
this ->update_pet (body, response);
144
- } catch (std::runtime_error & e) {
145
- // send a 400 error
146
- response.send (Pistache::Http::Code::Bad_Request, e.what ());
147
- return ;
164
+ } catch (nlohmann::detail::exception &e) {
165
+ // send a 400 error
166
+ response.send (Pistache::Http::Code::Bad_Request, e.what ());
167
+ return ;
168
+ } catch (std::runtime_error &e) {
169
+ // send a 500 error
170
+ response.send (Pistache::Http::Code::Internal_Server_Error, e.what ());
171
+ return ;
148
172
}
149
173
150
174
}
151
175
void PetApi::update_pet_with_form_handler (const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
152
176
try {
153
177
this ->update_pet_with_form (request, response);
154
- } catch (std::runtime_error & e) {
155
- // send a 400 error
156
- response.send (Pistache::Http::Code::Bad_Request, e.what ());
157
- return ;
178
+ } catch (nlohmann::detail::exception &e) {
179
+ // send a 400 error
180
+ response.send (Pistache::Http::Code::Bad_Request, e.what ());
181
+ return ;
182
+ } catch (std::runtime_error &e) {
183
+ // send a 500 error
184
+ response.send (Pistache::Http::Code::Internal_Server_Error, e.what ());
185
+ return ;
158
186
}
159
187
160
188
}
161
189
void PetApi::upload_file_handler (const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
162
190
try {
163
191
this ->upload_file (request, response);
164
- } catch (std::runtime_error & e) {
165
- // send a 400 error
166
- response.send (Pistache::Http::Code::Bad_Request, e.what ());
167
- return ;
192
+ } catch (nlohmann::detail::exception &e) {
193
+ // send a 400 error
194
+ response.send (Pistache::Http::Code::Bad_Request, e.what ());
195
+ return ;
196
+ } catch (std::runtime_error &e) {
197
+ // send a 500 error
198
+ response.send (Pistache::Http::Code::Internal_Server_Error, e.what ());
199
+ return ;
168
200
}
169
201
170
202
}
0 commit comments