| | | 1 | | namespace TeleFlow.Telegram.I18n.Fluent; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents a Fluent lookup, argument, function, or formatting failure for one message and locale. |
| | | 5 | | /// Diagnostic text deliberately excludes argument values and translated message contents. |
| | | 6 | | /// </summary> |
| | | 7 | | public sealed class FluentLocalizationException : InvalidOperationException |
| | | 8 | | { |
| | | 9 | | public FluentLocalizationException(string messageId, Locale locale, string reason) |
| | 3 | 10 | | : base(CreateMessage(messageId, locale, reason)) |
| | | 11 | | { |
| | | 12 | | MessageId = messageId; |
| | | 13 | | Locale = locale; |
| | 3 | 14 | | } |
| | | 15 | | |
| | | 16 | | public FluentLocalizationException( |
| | | 17 | | string messageId, |
| | | 18 | | Locale locale, |
| | | 19 | | string reason, |
| | | 20 | | Exception innerException) |
| | 3 | 21 | | : base(CreateMessage(messageId, locale, reason), innerException) |
| | | 22 | | { |
| | | 23 | | MessageId = messageId; |
| | | 24 | | Locale = locale; |
| | 3 | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Gets the requested Fluent message or message-attribute identifier. |
| | | 29 | | /// </summary> |
| | | 30 | | public string MessageId { get; } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Gets the requested locale before exact, parent, and fallback catalog selection. |
| | | 34 | | /// </summary> |
| | | 35 | | public Locale Locale { get; } |
| | | 36 | | |
| | | 37 | | private static string CreateMessage(string messageId, Locale locale, string reason) |
| | | 38 | | { |
| | 6 | 39 | | return $"Fluent message '{messageId}' could not be formatted for locale '{locale.Name}': {reason}"; |
| | | 40 | | } |
| | | 41 | | } |