// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // using System; namespace Microsoft.SqlTools.EditorServices.Utility { internal static class ObjectExtensions { /// /// Extension to evaluate an object's ToString() method in an exception safe way. This will /// extension method will not throw. /// /// The object on which to call ToString() /// The ToString() return value or a suitable error message is that throws. public static string SafeToString(this object obj) { string str; try { str = obj.ToString(); } catch (Exception ex) { str = $""; } return str; } } }