Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,56 @@ namespace Azure.Sdk.Tools.Cli.Models;

public class Response
{
/// <summary>
/// ResponseError represents a single error message associated with the response.
/// </summary>
[JsonPropertyName("response_error")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ResponseError { get; set; }

/// <summary>
/// ResponseErrors represents a list of error messages associated with the response.
/// </summary>
[JsonPropertyName("response_errors")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string> ResponseErrors { get; set; }

/// <summary>
/// NextSteps provides guidance or recommended actions regarding the response.
/// </summary>
[JsonPropertyName("next_steps")]
Comment thread
samvaity marked this conversation as resolved.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Comment thread
l0lawrence marked this conversation as resolved.
public List<string>? NextSteps { get; set; }

protected string ToString(StringBuilder value)
{
return ToString(value.ToString());
}

protected string ToString(string value)
{
List<string> errors = [];
List<string> messages = [];
Comment thread
l0lawrence marked this conversation as resolved.
if (!string.IsNullOrEmpty(ResponseError))
{
errors.Add("[ERROR] " + ResponseError);
messages.Add("[ERROR] " + ResponseError);
}
foreach (var error in ResponseErrors ?? [])
{
errors.Add("[ERROR] " + error);
messages.Add("[ERROR] " + error);
}

if (NextSteps?.Count > 0)
{
messages.Add("[NEXT STEPS]");
foreach (var step in NextSteps)
{
messages.Add(step);
}
Comment thread
l0lawrence marked this conversation as resolved.
}

if (errors.Count > 0)
if (messages.Count > 0)
{
value = string.Join(Environment.NewLine, errors);
value = string.Join(Environment.NewLine, messages);
Comment thread
l0lawrence marked this conversation as resolved.
Comment thread
l0lawrence marked this conversation as resolved.
}

return value;
Expand Down
Loading