Got at least one data fetching method working; turns out, we can't use a patched LogicStack to get the data

This commit is contained in:
2026-01-14 22:11:11 +01:00
parent 40a8431464
commit 3f7122d30a
350 changed files with 41444 additions and 119 deletions

View File

@@ -0,0 +1,51 @@
using System;
namespace EmbedIO.WebSockets
{
/// <summary>
/// The exception that is thrown when a WebSocket gets a fatal error.
/// </summary>
#pragma warning disable CA1032 // Implement standard exception constructors - this class doesn't need public constructors.
public class WebSocketException : Exception
#pragma warning restore CA1032
{
internal WebSocketException(string? message = null)
: this(CloseStatusCode.Abnormal, message)
{
// Ignore
}
internal WebSocketException(CloseStatusCode code, Exception? innerException = null)
: this(code, null, innerException)
{
}
internal WebSocketException(CloseStatusCode code, string? message, Exception? innerException = null)
: base(message ?? GetMessage(code), innerException)
{
Code = code;
}
/// <summary>
/// Gets the status code indicating the cause of the exception.
/// </summary>
/// <value>
/// One of the <see cref="CloseStatusCode"/> enum values, represents the status code
/// indicating the cause of the exception.
/// </value>
public CloseStatusCode Code { get; }
internal static string GetMessage(CloseStatusCode code) => code switch {
CloseStatusCode.ProtocolError => "A WebSocket protocol error has occurred.",
CloseStatusCode.UnsupportedData => "Unsupported data has been received.",
CloseStatusCode.Abnormal => "An exception has occurred.",
CloseStatusCode.InvalidData => "Invalid data has been received.",
CloseStatusCode.PolicyViolation => "A policy violation has occurred.",
CloseStatusCode.TooBig => "A too big message has been received.",
CloseStatusCode.MandatoryExtension => "WebSocket client didn't receive expected extension(s).",
CloseStatusCode.ServerError => "WebSocket server got an internal error.",
CloseStatusCode.TlsHandshakeFailure => "An error has occurred during a TLS handshake.",
_ => string.Empty
};
}
}