public static void CheckResponseAndThrowIfNeeded(this IRestResponse response) { response.EnsureSuccessStatusCode(); if (response.ErrorException != null) { throw response.ErrorException; } var msg = response.GetH3NonWarnings(); if (msg?.StartsWith("Error:") == true) { msg = msg.Substring(6).Trim(); throw new MailmanException(msg); } }