Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardvanRooijen committed May 1, 2020
2 parents eec352b + f6f3a51 commit 1d957b1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Solutions/Stacker.Cli/BufferClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Stacker.Cli
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Stacker.Cli.Configuration;
using Stacker.Cli.Contracts.Buffer;
using Stacker.Cli.Contracts.Configuration;
Expand Down Expand Up @@ -62,10 +63,16 @@ public async Task UploadAsync(IEnumerable<string> content, string profileId)

if (!response.IsSuccessStatusCode)
{
Console.WriteLine($"Buffering Failed {response.StatusCode} - {response.ReasonPhrase}");
var errorContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var error = JsonConvert.DeserializeObject<BufferError>(errorContent);

Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"Buffering Failed: {error.Message}");
Console.WriteLine();
Console.ResetColor();
}
}
}
}
}
}
}
24 changes: 24 additions & 0 deletions Solutions/Stacker.Cli/BufferError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// <copyright file="BufferError.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

namespace Stacker.Cli
{
using System.Collections.Generic;
using Newtonsoft.Json;

public class BufferError
{
[JsonProperty("success")]
public bool Success { get; set; }

[JsonProperty("message")]
public string Message { get; set; }

[JsonProperty("code")]
public int Code { get; set; }

[JsonProperty("errored_profiles")]
public IEnumerable<Profiles> ErroredProfiles { get; set; }
}
}
14 changes: 14 additions & 0 deletions Solutions/Stacker.Cli/Profiles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// <copyright file="Profiles.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

namespace Stacker.Cli
{
using Newtonsoft.Json;

public class Profiles
{
[JsonProperty("profile_id")]
public string ProfileId { get; set; }
}
}

0 comments on commit 1d957b1

Please sign in to comment.