@@ -77,143 +77,143 @@ macro_rules! http_error {
77
77
#[ macro_export]
78
78
macro_rules! bad_request {
79
79
( $( $arg: tt) * ) => { {
80
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: BAD_REQUEST ) )
80
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: BAD_REQUEST )
81
81
} }
82
82
}
83
83
84
84
/// Construct an `Error` with `StatusCode::UNAUTHORIZED` from a string or existing non-anyhow error value.
85
85
#[ macro_export]
86
86
macro_rules! unauthorized {
87
87
( $( $arg: tt) * ) => { {
88
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: UNAUTHORIZED ) )
88
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: UNAUTHORIZED )
89
89
} }
90
90
}
91
91
92
92
/// Construct an `Error` with `StatusCode::PAYMENT_REQUIRED` from a string or existing non-anyhow error value.
93
93
#[ macro_export]
94
94
macro_rules! payment_required {
95
95
( $( $arg: tt) * ) => { {
96
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: PAYMENT_REQUIRED ) )
96
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: PAYMENT_REQUIRED )
97
97
} }
98
98
}
99
99
100
100
/// Construct an `Error` with `StatusCode::FORBIDDEN` from a string or existing non-anyhow error value.
101
101
#[ macro_export]
102
102
macro_rules! forbidden {
103
103
( $( $arg: tt) * ) => { {
104
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: FORBIDDEN ) )
104
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: FORBIDDEN )
105
105
} }
106
106
}
107
107
108
108
/// Construct an `Error` with `StatusCode::NOT_FOUND` from a string or existing non-anyhow error value.
109
109
#[ macro_export]
110
110
macro_rules! not_found {
111
111
( $( $arg: tt) * ) => { {
112
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: NOT_FOUND ) )
112
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: NOT_FOUND )
113
113
} }
114
114
}
115
115
116
116
/// Construct an `Error` with `StatusCode::METHOD_NOT_ALLOWED` from a string or existing non-anyhow error value.
117
117
#[ macro_export]
118
118
macro_rules! method_not_allowed {
119
119
( $( $arg: tt) * ) => { {
120
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: METHOD_NOT_ALLOWED ) )
120
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: METHOD_NOT_ALLOWED )
121
121
} }
122
122
}
123
123
124
124
/// Construct an `Error` with `StatusCode::NOT_ACCEPTABLE` from a string or existing non-anyhow error value.
125
125
#[ macro_export]
126
126
macro_rules! not_acceptable {
127
127
( $( $arg: tt) * ) => { {
128
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: NOT_ACCEPTABLE ) )
128
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: NOT_ACCEPTABLE )
129
129
} }
130
130
}
131
131
132
132
/// Construct an `Error` with `StatusCode::PROXY_AUTHENTICATION_REQUIRED` from a string or existing non-anyhow error value.
133
133
#[ macro_export]
134
134
macro_rules! proxy_authentication_required {
135
135
( $( $arg: tt) * ) => { {
136
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: PROXY_AUTHENTICATION_REQUIRED ) )
136
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: PROXY_AUTHENTICATION_REQUIRED )
137
137
} }
138
138
}
139
139
140
140
/// Construct an `Error` with `StatusCode::REQUEST_TIMEOUT` from a string or existing non-anyhow error value.
141
141
#[ macro_export]
142
142
macro_rules! request_timeout {
143
143
( $( $arg: tt) * ) => { {
144
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: REQUEST_TIMEOUT ) )
144
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: REQUEST_TIMEOUT )
145
145
} }
146
146
}
147
147
148
148
/// Construct an `Error` with `StatusCode::CONFLICT` from a string or existing non-anyhow error value.
149
149
#[ macro_export]
150
150
macro_rules! conflict {
151
151
( $( $arg: tt) * ) => { {
152
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: CONFLICT ) )
152
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: CONFLICT )
153
153
} }
154
154
}
155
155
156
156
/// Construct an `Error` with `StatusCode::GONE` from a string or existing non-anyhow error value.
157
157
#[ macro_export]
158
158
macro_rules! gone {
159
159
( $( $arg: tt) * ) => { {
160
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: GONE ) )
160
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: GONE )
161
161
} }
162
162
}
163
163
164
164
/// Construct an `Error` with `StatusCode::LENGTH_REQUIRED` from a string or existing non-anyhow error value.
165
165
#[ macro_export]
166
166
macro_rules! length_required {
167
167
( $( $arg: tt) * ) => { {
168
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: LENGTH_REQUIRED ) )
168
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: LENGTH_REQUIRED )
169
169
} }
170
170
}
171
171
172
172
/// Construct an `Error` with `StatusCode::PRECONDITION_FAILED` from a string or existing non-anyhow error value.
173
173
#[ macro_export]
174
174
macro_rules! precondition_failed {
175
175
( $( $arg: tt) * ) => { {
176
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: PRECONDITION_FAILED ) )
176
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: PRECONDITION_FAILED )
177
177
} }
178
178
}
179
179
180
180
/// Construct an `Error` with `StatusCode::PAYLOAD_TOO_LARGE` from a string or existing non-anyhow error value.
181
181
#[ macro_export]
182
182
macro_rules! payload_too_large {
183
183
( $( $arg: tt) * ) => { {
184
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: PAYLOAD_TOO_LARGE ) )
184
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: PAYLOAD_TOO_LARGE )
185
185
} }
186
186
}
187
187
188
188
/// Construct an `Error` with `StatusCode::URI_TOO_LONG` from a string or existing non-anyhow error value.
189
189
#[ macro_export]
190
190
macro_rules! uri_too_long {
191
191
( $( $arg: tt) * ) => { {
192
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: URI_TOO_LONG ) )
192
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: URI_TOO_LONG )
193
193
} }
194
194
}
195
195
196
196
/// Construct an `Error` with `StatusCode::UNSUPPORTED_MEDIA_TYPE` from a string or existing non-anyhow error value.
197
197
#[ macro_export]
198
198
macro_rules! unsupported_media_type {
199
199
( $( $arg: tt) * ) => { {
200
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: UNSUPPORTED_MEDIA_TYPE ) )
200
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: UNSUPPORTED_MEDIA_TYPE )
201
201
} }
202
202
}
203
203
204
204
/// Construct an `Error` with `StatusCode::RANGE_NOT_SATISFIABLE` from a string or existing non-anyhow error value.
205
205
#[ macro_export]
206
206
macro_rules! range_not_satisfiable {
207
207
( $( $arg: tt) * ) => { {
208
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: RANGE_NOT_SATISFIABLE ) )
208
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: RANGE_NOT_SATISFIABLE )
209
209
} }
210
210
}
211
211
212
212
/// Construct an `Error` with `StatusCode::EXPECTATION_FAILED` from a string or existing non-anyhow error value.
213
213
#[ macro_export]
214
214
macro_rules! expectation_failed {
215
215
( $( $arg: tt) * ) => { {
216
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: EXPECTATION_FAILED ) )
216
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: EXPECTATION_FAILED )
217
217
} }
218
218
}
219
219
@@ -222,70 +222,70 @@ macro_rules! expectation_failed {
222
222
#[ macro_export]
223
223
macro_rules! internal_server_error {
224
224
( $( $arg: tt) * ) => { {
225
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: INTERNAL_SERVER_ERROR ) )
225
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: INTERNAL_SERVER_ERROR )
226
226
} }
227
227
}
228
228
229
229
/// Construct an `Error` with `StatusCode::NOT_IMPLEMENTED` from a string or existing non-anyhow error value.
230
230
#[ macro_export]
231
231
macro_rules! not_implemented {
232
232
( $( $arg: tt) * ) => { {
233
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: NOT_IMPLEMENTED ) )
233
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: NOT_IMPLEMENTED )
234
234
} }
235
235
}
236
236
237
237
/// Construct an `Error` with `StatusCode::BAD_GATEWAY` from a string or existing non-anyhow error value.
238
238
#[ macro_export]
239
239
macro_rules! bad_gateway {
240
240
( $( $arg: tt) * ) => { {
241
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: BAD_GATEWAY ) )
241
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: BAD_GATEWAY )
242
242
} }
243
243
}
244
244
245
245
/// Construct an `Error` with `StatusCode::SERVICE_UNAVAILABLE` from a string or existing non-anyhow error value.
246
246
#[ macro_export]
247
247
macro_rules! service_unavailable {
248
248
( $( $arg: tt) * ) => { {
249
- $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: SERVICE_UNAVAILABLE ) )
249
+ $crate:: Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: SERVICE_UNAVAILABLE )
250
250
} }
251
251
}
252
252
253
253
/// Construct an `Error` with `StatusCode::GATEWAY_TIMEOUT` from a string or existing non-anyhow error value.
254
254
#[ macro_export]
255
255
macro_rules! gateway_timeout {
256
256
( $( $arg: tt) * ) => { {
257
- Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: GATEWAY_TIMEOUT ) )
257
+ Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: GATEWAY_TIMEOUT )
258
258
} }
259
259
}
260
260
261
261
/// Construct an `Error` with `StatusCode::HTTP_VERSION_NOT_SUPPORTED` from a string or existing non-anyhow error value.
262
262
#[ macro_export]
263
263
macro_rules! http_version_not_supported {
264
264
( $( $arg: tt) * ) => { {
265
- Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: HTTP_VERSION_NOT_SUPPORTED ) )
265
+ Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: HTTP_VERSION_NOT_SUPPORTED )
266
266
} }
267
267
}
268
268
269
269
/// Construct an `Error` with `StatusCode::VARIANT_ALSO_NEGOTIATES` from a string or existing non-anyhow error value.
270
270
#[ macro_export]
271
271
macro_rules! variant_also_negotiates {
272
272
( $( $arg: tt) * ) => { {
273
- Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: VARIANT_ALSO_NEGOTIATES ) )
273
+ Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: VARIANT_ALSO_NEGOTIATES )
274
274
} }
275
275
}
276
276
277
277
/// Construct an `Error` with `StatusCode::INSUFFICIENT_STORAGE` from a string or existing non-anyhow error value.
278
278
#[ macro_export]
279
279
macro_rules! insufficient_storage {
280
280
( $( $arg: tt) * ) => { {
281
- Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: INSUFFICIENT_STORAGE ) )
281
+ Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: INSUFFICIENT_STORAGE )
282
282
} }
283
283
}
284
284
285
285
/// Construct an `Error` with `StatusCode::LOOP_DETECTED` from a string or existing non-anyhow error value.
286
286
#[ macro_export]
287
287
macro_rules! loop_detected {
288
288
( $( $arg: tt) * ) => { {
289
- Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( Some ( StatusCode :: LOOP_DETECTED ) )
289
+ Error :: from( anyhow:: anyhow!( $( $arg) * ) ) . with_status( StatusCode :: LOOP_DETECTED )
290
290
} }
291
291
}
0 commit comments