mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-06-05 09:13:44 -04:00
Rework architecture
This commit is contained in:
parent
130c0b6fe2
commit
8685a3d7e3
119 changed files with 1520 additions and 1560 deletions
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue