mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Make channel selection error info more accurate
This commit is contained in:
parent
dc70720ff7
commit
b677ce5aea
18
Bloxstrap/Exceptions/HttpResponseUnsuccessfulException.cs
Normal file
18
Bloxstrap/Exceptions/HttpResponseUnsuccessfulException.cs
Normal file
@ -0,0 +1,18 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
namespace Bloxstrap
|
||||
using Bloxstrap.Exceptions;
|
||||
|
||||
namespace Bloxstrap
|
||||
{
|
||||
public static class RobloxDeployment
|
||||
{
|
||||
@ -109,7 +111,7 @@
|
||||
$"\tResponse: {rawResponse}"
|
||||
);
|
||||
|
||||
throw new Exception($"Could not get latest deploy for channel {channel}! (HTTP {deployInfoResponse.StatusCode})");
|
||||
throw new HttpResponseUnsuccessfulException(deployInfoResponse);
|
||||
}
|
||||
|
||||
clientVersion = JsonSerializer.Deserialize<ClientVersion>(rawResponse)!;
|
||||
|
@ -100,7 +100,7 @@
|
||||
<ui:ProgressRing Grid.Column="0" Margin="6" IsIndeterminate="True" Visibility="{Binding LoadingSpinnerVisibility, Mode=OneWay}" />
|
||||
<Image Grid.Column="0" Margin="6" Width="60" Height="60" Visibility="{Binding LoadingErrorVisibility, Mode=OneWay}" RenderOptions.BitmapScalingMode="HighQuality" Source="pack://application:,,,/Resources/MessageBox/Error.png" />
|
||||
|
||||
<TextBlock Grid.Column="1" Margin="16" VerticalAlignment="Center" Text="{Binding ChannelInfoLoadingText, Mode=OneWay}" />
|
||||
<TextBlock Grid.Column="1" Margin="16" VerticalAlignment="Center" Text="{Binding ChannelInfoLoadingText, Mode=OneWay}" TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</ui:CardExpander>
|
||||
|
@ -1,5 +1,7 @@
|
||||
using System.Windows;
|
||||
|
||||
using Bloxstrap.Exceptions;
|
||||
|
||||
namespace Bloxstrap.UI.ViewModels.Menu
|
||||
{
|
||||
public class BehaviourViewModel : NotifyPropertyChangedViewModel
|
||||
@ -39,11 +41,30 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
||||
OnPropertyChanged(nameof(ChannelWarningVisibility));
|
||||
OnPropertyChanged(nameof(ChannelDeployInfo));
|
||||
}
|
||||
catch (Exception)
|
||||
catch (HttpResponseUnsuccessfulException ex)
|
||||
{
|
||||
LoadingSpinnerVisibility = Visibility.Collapsed;
|
||||
LoadingErrorVisibility = Visibility.Visible;
|
||||
ChannelInfoLoadingText = "Could not get deployment information! Is the channel name valid?";
|
||||
|
||||
ChannelInfoLoadingText = ex.ResponseMessage.StatusCode switch
|
||||
{
|
||||
HttpStatusCode.NotFound => "The specified channel name does not exist.",
|
||||
_ => $"Failed to fetch information! (HTTP {ex.ResponseMessage.StatusCode})",
|
||||
};
|
||||
|
||||
OnPropertyChanged(nameof(LoadingSpinnerVisibility));
|
||||
OnPropertyChanged(nameof(LoadingErrorVisibility));
|
||||
OnPropertyChanged(nameof(ChannelInfoLoadingText));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoadingSpinnerVisibility = Visibility.Collapsed;
|
||||
LoadingErrorVisibility = Visibility.Visible;
|
||||
|
||||
App.Logger.WriteLine("[BehaviourViewModel::LoadChannelDeployInfo] An exception occurred while fetching channel information");
|
||||
App.Logger.WriteLine($"[BehaviourViewModel::LoadChannelDeployInfo] {ex}");
|
||||
|
||||
ChannelInfoLoadingText = $"Failed to fetch information! ({ex.Message})";
|
||||
|
||||
OnPropertyChanged(nameof(LoadingSpinnerVisibility));
|
||||
OnPropertyChanged(nameof(LoadingErrorVisibility));
|
||||
|
Loading…
Reference in New Issue
Block a user