This commit is contained in:
Tyrrrz
2021-02-22 03:15:09 +02:00
parent bed0ade732
commit ebe4d58a42
101 changed files with 330 additions and 310 deletions

View File

@@ -0,0 +1,55 @@
using System;
using System.Net.Http;
namespace DiscordChatExporter.Core.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 Forbidden()
{
const string message = "Access is forbidden.";
return new DiscordChatExporterException(message);
}
internal static DiscordChatExporterException NotFound()
{
const string message = "Requested resource does not exist.";
return new DiscordChatExporterException(message);
}
internal static DiscordChatExporterException ChannelIsEmpty()
{
var message = $"No messages for the specified period.";
return new DiscordChatExporterException(message);
}
}
}