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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! The contract a SurrealDB error type implements to reach the wire.
//!
//! Each layer of the engine owns its own error enum, but they all have to
//! arrive at the client as one [`surrealdb_types::Error`]. [`LeafError`] is
//! that conversion, stated once so every layer answers the same question the
//! same way.
use Error as TypesError;
/// Converts an error into its public form.
///
/// Implement [`map_kind`](LeafError::map_kind) and nothing else.
///
/// # Nesting
///
/// When one error wraps another, the outer arm must call the inner error's
/// `map_kind`, **not** its `to_types_error`. `to_types_error` attaches the
/// cause, so calling it inward attaches one at each level and the outer
/// attachment silently replaces the inner one. `map_kind` classifies without
/// touching the cause, which is why it is the only method to write and
/// `to_types_error` is provided.
/// A variant that reaches clients as an untyped internal error only because it
/// always has.
///
/// Behaviourally identical to [`TypesError::internal`]. It exists to keep those
/// variants greppable and countable while they are worked off, so that a
/// deliberate `internal` and an unclassified one do not look alike.