1
Fork 0

Make translate_message return result and add tests

This commit is contained in:
mejrs 2023-01-08 23:35:43 +01:00
parent 0b5d6ae5db
commit 262ff86138
7 changed files with 224 additions and 17 deletions

View file

@ -46,6 +46,7 @@ use rustc_span::{Loc, Span};
use std::any::Any;
use std::borrow::Cow;
use std::error::Report;
use std::fmt;
use std::hash::Hash;
use std::num::NonZeroUsize;
@ -65,6 +66,8 @@ mod lock;
pub mod registry;
mod snippet;
mod styled_buffer;
#[cfg(test)]
mod tests;
pub mod translation;
pub use diagnostic_builder::IntoDiagnostic;
@ -627,7 +630,14 @@ impl Handler {
) -> SubdiagnosticMessage {
let inner = self.inner.borrow();
let args = crate::translation::to_fluent_args(args);
SubdiagnosticMessage::Eager(inner.emitter.translate_message(&message, &args).to_string())
SubdiagnosticMessage::Eager(
inner
.emitter
.translate_message(&message, &args)
.map_err(Report::new)
.unwrap()
.to_string(),
)
}
// This is here to not allow mutation of flags;