mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 18:11:27 -07:00
Add verbosity for HTTP response exceptions
This commit is contained in:
parent
dae1dfd824
commit
767783ae22
@ -162,11 +162,14 @@ namespace Bloxstrap
|
|||||||
Logger.WriteLine(LOG_IDENT, "Connectivity check failed!");
|
Logger.WriteLine(LOG_IDENT, "Connectivity check failed!");
|
||||||
Logger.WriteException(LOG_IDENT, ex);
|
Logger.WriteException(LOG_IDENT, ex);
|
||||||
|
|
||||||
|
if (ex.GetType() == typeof(AggregateException))
|
||||||
|
ex = ex.InnerException!;
|
||||||
|
|
||||||
Controls.ShowMessageBox(
|
Controls.ShowMessageBox(
|
||||||
"Bloxstrap is unable to connect to the internet. Please check your network configuration and try again.\n" +
|
"Bloxstrap is unable to connect to the internet. Please check your network configuration and try again.\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"More information:\n" +
|
"More information:\n" +
|
||||||
ex.InnerException!.Message,
|
ex.Message,
|
||||||
MessageBoxImage.Error,
|
MessageBoxImage.Error,
|
||||||
MessageBoxButton.OK
|
MessageBoxButton.OK
|
||||||
);
|
);
|
||||||
|
19
Bloxstrap/Exceptions/HttpResponseException.cs
Normal file
19
Bloxstrap/Exceptions/HttpResponseException.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Bloxstrap.Exceptions
|
||||||
|
{
|
||||||
|
internal class HttpResponseException : Exception
|
||||||
|
{
|
||||||
|
public HttpResponseMessage ResponseMessage { get; }
|
||||||
|
|
||||||
|
public HttpResponseException(HttpResponseMessage responseMessage)
|
||||||
|
: base($"Could not connect to {responseMessage.RequestMessage!.RequestUri} because it returned HTTP {(int)responseMessage.StatusCode} ({responseMessage.ReasonPhrase})")
|
||||||
|
{
|
||||||
|
ResponseMessage = responseMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Bloxstrap.Exceptions
|
|
||||||
{
|
|
||||||
internal class HttpResponseUnsuccessfulException : Exception
|
|
||||||
{
|
|
||||||
public HttpResponseMessage ResponseMessage { get; }
|
|
||||||
|
|
||||||
public HttpResponseUnsuccessfulException(HttpResponseMessage responseMessage) : base()
|
|
||||||
{
|
|
||||||
ResponseMessage = responseMessage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -128,7 +128,7 @@ namespace Bloxstrap
|
|||||||
$"\tResponse: {rawResponse}"
|
$"\tResponse: {rawResponse}"
|
||||||
);
|
);
|
||||||
|
|
||||||
throw new HttpResponseUnsuccessfulException(deployInfoResponse);
|
throw new HttpResponseException(deployInfoResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
clientVersion = JsonSerializer.Deserialize<ClientVersion>(rawResponse)!;
|
clientVersion = JsonSerializer.Deserialize<ClientVersion>(rawResponse)!;
|
||||||
|
@ -40,7 +40,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
|
|
||||||
OnPropertyChanged(nameof(ChannelDeployInfo));
|
OnPropertyChanged(nameof(ChannelDeployInfo));
|
||||||
}
|
}
|
||||||
catch (HttpResponseUnsuccessfulException ex)
|
catch (HttpResponseException ex)
|
||||||
{
|
{
|
||||||
ShowLoadingError = true;
|
ShowLoadingError = true;
|
||||||
OnPropertyChanged(nameof(ShowLoadingError));
|
OnPropertyChanged(nameof(ShowLoadingError));
|
||||||
@ -48,7 +48,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
ChannelInfoLoadingText = ex.ResponseMessage.StatusCode switch
|
ChannelInfoLoadingText = ex.ResponseMessage.StatusCode switch
|
||||||
{
|
{
|
||||||
HttpStatusCode.NotFound => "The specified channel name does not exist.",
|
HttpStatusCode.NotFound => "The specified channel name does not exist.",
|
||||||
_ => $"Failed to fetch information! (HTTP {ex.ResponseMessage.StatusCode})",
|
_ => $"Failed to fetch information! (HTTP {(int)ex.ResponseMessage.StatusCode} - {ex.ResponseMessage.ReasonPhrase})",
|
||||||
};
|
};
|
||||||
OnPropertyChanged(nameof(ChannelInfoLoadingText));
|
OnPropertyChanged(nameof(ChannelInfoLoadingText));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user