You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
44 lines
1.2 KiB
using System;
|
|
using System.Net.Http;
|
|
|
|
namespace DiscordChatExporter.Core.Exceptions;
|
|
|
|
public partial class DiscordChatExporterException : Exception
|
|
{
|
|
public bool IsFatal { get; }
|
|
|
|
public DiscordChatExporterException(string message, bool isFatal = false)
|
|
: base(message)
|
|
{
|
|
IsFatal = isFatal;
|
|
}
|
|
}
|
|
|
|
public partial class DiscordChatExporterException
|
|
{
|
|
internal static DiscordChatExporterException FailedHttpRequest(HttpResponseMessage response)
|
|
{
|
|
var message = $@"
|
|
Failed to perform an HTTP request.
|
|
|
|
[Request]
|
|
{response.RequestMessage}
|
|
|
|
[Response]
|
|
{response}";
|
|
|
|
return new DiscordChatExporterException(message.Trim(), true);
|
|
}
|
|
|
|
internal static DiscordChatExporterException Unauthorized() =>
|
|
new("Authentication token is invalid.", true);
|
|
|
|
internal static DiscordChatExporterException Forbidden() =>
|
|
new("Access is forbidden.");
|
|
|
|
internal static DiscordChatExporterException NotFound(string resourceId) =>
|
|
new($"Requested resource ({resourceId}) does not exist.");
|
|
|
|
internal static DiscordChatExporterException ChannelIsEmpty() =>
|
|
new("Channel is empty or contains no messages for the specified period.");
|
|
} |