mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-10 20:02:31 +00:00
Improve error reporting on unexpected HTTP status code
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exceptions;
|
||||
|
||||
public partial class DiscordChatExporterException : Exception
|
||||
public class DiscordChatExporterException : Exception
|
||||
{
|
||||
public bool IsFatal { get; }
|
||||
|
||||
@@ -12,33 +11,4 @@ public partial class DiscordChatExporterException : Exception
|
||||
{
|
||||
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.");
|
||||
}
|
||||
Reference in New Issue
Block a user