@@ -79,7 +79,7 @@ impl FromStr for Config {
79
79
80
80
/// Load a `Config` from some string.
81
81
fn from_str ( src : & str ) -> Result < Self > {
82
- toml:: from_str ( src) . chain_err ( || Error :: from ( "Invalid configuration file" ) )
82
+ toml:: from_str ( src) . with_context ( || "Invalid configuration file" )
83
83
}
84
84
}
85
85
@@ -88,9 +88,9 @@ impl Config {
88
88
pub fn from_disk < P : AsRef < Path > > ( config_file : P ) -> Result < Config > {
89
89
let mut buffer = String :: new ( ) ;
90
90
File :: open ( config_file)
91
- . chain_err ( || "Unable to open the configuration file" ) ?
91
+ . with_context ( || "Unable to open the configuration file" ) ?
92
92
. read_to_string ( & mut buffer)
93
- . chain_err ( || "Couldn't read the file" ) ?;
93
+ . with_context ( || "Couldn't read the file" ) ?;
94
94
95
95
Config :: from_str ( & buffer)
96
96
}
@@ -176,11 +176,14 @@ impl Config {
176
176
/// HTML renderer is refactored to be less coupled to `mdbook` internals.
177
177
#[ doc( hidden) ]
178
178
pub fn html_config ( & self ) -> Option < HtmlConfig > {
179
- match self . get_deserialized_opt ( "output.html" ) {
179
+ match self
180
+ . get_deserialized_opt ( "output.html" )
181
+ . with_context ( || "Parsing configuration [output.html]" )
182
+ {
180
183
Ok ( Some ( config) ) => Some ( config) ,
181
184
Ok ( None ) => None ,
182
185
Err ( e) => {
183
- utils:: log_backtrace ( & e. chain_err ( || "Parsing configuration [output.html]" ) ) ;
186
+ utils:: log_backtrace ( & e) ;
184
187
None
185
188
}
186
189
}
@@ -208,7 +211,7 @@ impl Config {
208
211
value
209
212
. clone ( )
210
213
. try_into ( )
211
- . chain_err ( || "Couldn't deserialize the value" )
214
+ . with_context ( || "Couldn't deserialize the value" )
212
215
} )
213
216
. transpose ( )
214
217
}
@@ -220,8 +223,8 @@ impl Config {
220
223
pub fn set < S : Serialize , I : AsRef < str > > ( & mut self , index : I , value : S ) -> Result < ( ) > {
221
224
let index = index. as_ref ( ) ;
222
225
223
- let value =
224
- Value :: try_from ( value ) . chain_err ( || "Unable to represent the item as a JSON Value" ) ?;
226
+ let value = Value :: try_from ( value )
227
+ . with_context ( || "Unable to represent the item as a JSON Value" ) ?;
225
228
226
229
if index. starts_with ( "book." ) {
227
230
self . book . update_value ( & index[ 5 ..] , value) ;
0 commit comments