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