File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -32,16 +32,19 @@ impl Span {
32
32
33
33
/// Record a single `field` to take `value`.
34
34
///
35
- /// Note that this silently fails if the field name wasn't mentioned when the span was created.
35
+ /// ### Panics
36
+ ///
37
+ /// If the field name wasn't mentioned when the span was created.
36
38
pub fn record < V > ( & self , field : & str , value : V ) -> & Self
37
39
where
38
40
V : field:: Value ,
39
41
{
40
42
if let Some ( ( _, _, meta) ) = & self . id {
41
43
let fields = meta. fields ( ) ;
42
- if let Some ( field) = fields. field ( field) {
43
- self . record_all ( & fields. value_set ( & [ ( & field, Some ( & value as & dyn field:: Value ) ) ] ) ) ;
44
- }
44
+ let field = fields
45
+ . field ( field)
46
+ . unwrap_or_else ( || panic ! ( "Field name '{field}' must be registered at creation time." ) ) ;
47
+ self . record_all ( & fields. value_set ( & [ ( & field, Some ( & value as & dyn field:: Value ) ) ] ) ) ;
45
48
}
46
49
self
47
50
}
You can’t perform that action at this time.
0 commit comments