1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Helper for turning a failed [`Result`] into a `500 Internal Server Error`
//! response while leaving a real trail behind.
//!
//! Every 500 an endpoint returns should be paired with an `ERROR`-level
//! trace event naming exactly what failed, so a `curl` returning a bare
//! `500` is never a dead end. We deliberately don't put the error detail in
//! the HTTP response body (callers shouldn't need to parse arbitrary
//! internal error strings, and we shouldn't leak implementation details),
//! but it must always be visible in the server's logs.
//!
//! Implemented as a `macro_rules!` (rather than a function) so `tracing`
//! attributes the event to the actual call site instead of this module.
/// Log `$err` at `ERROR` with any extra `field = value` context, then
/// produce a `500 Internal Server Error` response.
///
/// ```ignore
/// Err(err) => internal_error!(err, bundle_id = %bundle_id),
/// ```
pub use internal_error;