about summary refs log tree commit diff
path: root/LibMatrix/Helpers/MessageFormatter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'LibMatrix/Helpers/MessageFormatter.cs')
-rw-r--r--LibMatrix/Helpers/MessageFormatter.cs9
1 files changed, 7 insertions, 2 deletions
diff --git a/LibMatrix/Helpers/MessageFormatter.cs b/LibMatrix/Helpers/MessageFormatter.cs
index ae02afc..d252e85 100644
--- a/LibMatrix/Helpers/MessageFormatter.cs
+++ b/LibMatrix/Helpers/MessageFormatter.cs
@@ -13,8 +13,7 @@ public static class MessageFormatter {
 
     public static RoomMessageEventContent FormatException(string error, Exception e) {
         return new RoomMessageEventContent(body: $"{error}: {e.Message}", messageType: "m.text") {
-            FormattedBody = $"<font color=\"#FF0000\">{error}: <pre>{e.Message}</pre>" +
-                            $"</font>",
+            FormattedBody = $"<font color=\"#FF0000\">{error}: <pre>{e.Message}</pre></font>",
             Format = "org.matrix.custom.html"
         };
     }
@@ -36,4 +35,10 @@ public static class MessageFormatter {
     public static string HtmlFormatMention(string id, string? displayName = null) {
         return $"<a href=\"https://matrix.to/#/{id}\">{displayName ?? id}</a>";
     }
+
+#region Extension functions
+
+    public static RoomMessageEventContent ToMatrixMessage(this Exception e, string error) => FormatException(error, e);
+
+#endregion
 }