File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1
- use eyre:: bail;
1
+ use eyre:: { ContextCompat , bail} ;
2
2
use serde:: { Deserialize , Serialize } ;
3
3
use toml:: value:: Date ;
4
4
@@ -21,12 +21,12 @@ pub struct FrontMatter {
21
21
/// the tuple.
22
22
pub fn parse ( markdown : & str ) -> eyre:: Result < ( FrontMatter , & str ) > {
23
23
if !markdown. starts_with ( "+++\n " ) {
24
- bail ! ( "markdown file must start with the line ` +++` " ) ;
24
+ bail ! ( "missing start of TOML front matter ( +++) " ) ;
25
25
}
26
26
let ( front_matter, content) = markdown
27
27
. trim_start_matches ( "+++\n " )
28
28
. split_once ( "\n +++\n " )
29
- . expect ( "couldn't find the end of the front matter: ` +++`" ) ;
29
+ . context ( "missing end of TOML front matter ( +++)" ) ? ;
30
30
31
31
Ok ( ( toml:: from_str ( front_matter) ?, content) )
32
32
}
@@ -63,7 +63,9 @@ mod tests {
63
63
64
64
for post in posts {
65
65
let content = fs:: read_to_string ( & post) . unwrap ( ) ;
66
- let normalized = normalize ( & content) . unwrap ( ) ;
66
+ let normalized = normalize ( & content) . unwrap_or_else ( |err| {
67
+ panic ! ( "failed to normalize {:?}: {err}" , post. file_name( ) . unwrap( ) ) ;
68
+ } ) ;
67
69
68
70
if content != normalized {
69
71
if env:: var ( "FIX_FRONT_MATTER" ) . is_ok ( ) {
You can’t perform that action at this time.
0 commit comments