internal static Dictionary <string, object> ToDictionary(this AzureClientError error) => new Dictionary <string, object>() { ["error_code"] = System.Convert.ToInt32(error), ["error_name"] = error.ToString(), ["error_description"] = error.ToDescription(), };
private void ExpectError(AzureClientError expectedError, Task <ExecutionResult> task) { var result = task.GetAwaiter().GetResult(); Assert.AreEqual(ExecuteStatus.Error, result.Status); Assert.IsInstanceOfType(result.Output, typeof(AzureClientError)); Assert.AreEqual(expectedError, (AzureClientError)result.Output); }
internal static string ToDescription(this AzureClientError error) { var attributes = error .GetType() .GetField(error.ToString()) .GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[]; return(attributes?.Length > 0 ? attributes[0].Description : string.Empty); }
internal static ExecutionResult ToExecutionResult(this AzureClientError azureClientError) => new ExecutionResult { Status = ExecuteStatus.Error, Output = azureClientError, };
public static string ToMarkdown(this AzureClientError error) => $"`{error.ToString()}`: {error.ToDescription()}";