Rework architecture

This commit is contained in:
Alexey Golub 2020-04-21 21:30:42 +03:00
parent 130c0b6fe2
commit 8685a3d7e3
119 changed files with 1520 additions and 1560 deletions

View file

@ -0,0 +1,59 @@
using System;
using System.Net.Http;
using DiscordChatExporter.Domain.Discord.Models;
namespace DiscordChatExporter.Domain.Exceptions
{
public partial class DiscordChatExporterException : Exception
{
public bool IsCritical { get; }
public DiscordChatExporterException(string message, bool isCritical = false)
: base(message)
{
IsCritical = isCritical;
}
}
public partial class DiscordChatExporterException
{
internal static DiscordChatExporterException FailedHttpRequest(HttpResponseMessage response)
{
var message = $@"
Failed to perform an HTTP request.
{response.RequestMessage}
{response}";
return new DiscordChatExporterException(message.Trim(), true);
}
internal static DiscordChatExporterException Unauthorized()
{
const string message = "Authentication token is invalid.";
return new DiscordChatExporterException(message);
}
internal static DiscordChatExporterException ChannelForbidden(string channel)
{
var message = $"Access to channel '{channel}' is forbidden.";
return new DiscordChatExporterException(message);
}
internal static DiscordChatExporterException ChannelDoesNotExist(string channel)
{
var message = $"Channel '{channel}' does not exist.";
return new DiscordChatExporterException(message);
}
internal static DiscordChatExporterException ChannelEmpty(string channel)
{
var message = $"Channel '{channel}' contains no messages for the specified period.";
return new DiscordChatExporterException(message);
}
internal static DiscordChatExporterException ChannelEmpty(Channel channel) =>
ChannelEmpty(channel.Name);
}
}