From 1045211985f7bb0dd1698523399bea917323199b Mon Sep 17 00:00:00 2001 From: 13xforever Date: Tue, 9 Aug 2022 17:18:07 +0500 Subject: [PATCH] noticed some weird exceptions, which I have no idea how they can happen --- Clients/CompatApiClient/Utils/Utils.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Clients/CompatApiClient/Utils/Utils.cs b/Clients/CompatApiClient/Utils/Utils.cs index 8b456639..8d17f9a0 100644 --- a/Clients/CompatApiClient/Utils/Utils.cs +++ b/Clients/CompatApiClient/Utils/Utils.cs @@ -8,8 +8,11 @@ public static class Utils private const long UnderMB = 1000 * 1024; private const long UnderGB = 1000 * 1024 * 1024; - public static string Trim(this string str, int maxLength) + public static string Trim(this string? str, int maxLength) { + if (str is null) + return ""; + if (str.Length > maxLength) return str[..(maxLength - 1)] + "…";