@@ -297,10 +297,28 @@ impl<'bundle> FluentBundle<'bundle> {
297
297
///
298
298
/// # Errors
299
299
///
300
- /// If the message id or path is not found in the bundle, `format`
301
- /// returns None. On Fluent processing errors after initial lookup
302
- /// `format` returns `Some((path, errors)`. `path` is the path you
303
- /// originally provided, and `errors` explains what went wrong.
300
+ /// If no message is found at `path`, then `format` returns `None`.
301
+ ///
302
+ /// In all other cases, `format` returns a string even if it
303
+ /// encountered errors. `format` uses two fallback techniques to
304
+ /// create the fallback string. If there are bad references in the
305
+ /// message, then they will be substituted with `'___'`. If there
306
+ /// are more extensive errors, then `format` will fall back to using
307
+ /// `path` itself as the formatted string. Sometimes, but not always,
308
+ /// these partial failures will emit extra error information in the
309
+ /// second term of the return tuple.
310
+ ///
311
+ /// ```
312
+ /// use fluent::bundle::FluentBundle;
313
+ ///
314
+ /// // Create a message with bad cyclic reference
315
+ /// let mut bundle = FluentBundle::new(&["en-US"]);
316
+ /// bundle.add_messages("foo = a { foo } b");
317
+ ///
318
+ /// // The result falls back to "___"
319
+ /// let value = bundle.format("foo", None);
320
+ /// assert_eq!(value, Some(("___".to_string(), vec![])));
321
+ /// ```
304
322
pub fn format (
305
323
& self ,
306
324
path : & str ,
0 commit comments