// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-namespace System.Net.Quic
+namespace System.Net.Quic;
+
+/// <summary>
+/// Defines the various error conditions for <see cref="QuicListener"/>, <see cref="QuicConnection"/> and <see cref="QuicStream"/> operations.
+/// </summary>
+public enum QuicError
{
/// <summary>
- /// Defines the various error conditions for <see cref="QuicListener"/>, <see cref="QuicConnection"/> and <see cref="QuicStream"/> operations.
+ /// No error.
/// </summary>
- public enum QuicError
- {
- /// <summary>
- /// No error.
- /// </summary>
- Success,
+ Success,
- /// <summary>
- /// An internal implementation error has occurred.
- /// </summary>
- InternalError,
+ /// <summary>
+ /// An internal implementation error has occurred.
+ /// </summary>
+ InternalError,
- /// <summary>
- /// The connection was aborted by the peer. This error is associated with an application-level error code.
- /// </summary>
- ConnectionAborted,
+ /// <summary>
+ /// The connection was aborted by the peer. This error is associated with an application-level error code.
+ /// </summary>
+ ConnectionAborted,
- /// <summary>
- /// The read or write direction of the stream was aborted by the peer. This error is associated with an application-level error code.
- /// </summary>
- StreamAborted,
+ /// <summary>
+ /// The read or write direction of the stream was aborted by the peer. This error is associated with an application-level error code.
+ /// </summary>
+ StreamAborted,
- /// <summary>
- /// The connection timed out waiting for a response from the peer.
- /// </summary>
- ConnectionTimeout = 6,
+ /// <summary>
+ /// The connection timed out waiting for a response from the peer.
+ /// </summary>
+ ConnectionTimeout = 6,
- /// <summary>
- /// The server refused the connection.
- /// </summary>
- ConnectionRefused = 8,
+ /// <summary>
+ /// The server refused the connection.
+ /// </summary>
+ ConnectionRefused = 8,
- /// <summary>
- /// A version negotiation error was encountered.
- /// </summary>
- VersionNegotiationError,
+ /// <summary>
+ /// A version negotiation error was encountered.
+ /// </summary>
+ VersionNegotiationError,
- /// <summary>
- /// The connection timed out from inactivity.
- /// </summary>
- ConnectionIdle,
+ /// <summary>
+ /// The connection timed out from inactivity.
+ /// </summary>
+ ConnectionIdle,
- /// <summary>
- /// The operation has been aborted.
- /// </summary>
- OperationAborted = 12,
+ /// <summary>
+ /// The operation has been aborted.
+ /// </summary>
+ OperationAborted = 12,
- /// <summary>
- /// Another QUIC listener is already listening on one of the requested application protocols on the same port.
- /// </summary>
- AlpnInUse,
+ /// <summary>
+ /// Another QUIC listener is already listening on one of the requested application protocols on the same port.
+ /// </summary>
+ AlpnInUse,
- /// <summary>
- /// Operation failed because peer transport error occurred.
- /// </summary>
- TransportError,
+ /// <summary>
+ /// Operation failed because peer transport error occurred.
+ /// </summary>
+ TransportError,
- /// <summary>
- /// An error occurred in user provided callback.
- /// </summary>
- CallbackError,
- }
+ /// <summary>
+ /// An error occurred in user provided callback.
+ /// </summary>
+ CallbackError,
}
using System.IO;
-namespace System.Net.Quic
+namespace System.Net.Quic;
+
+/// <summary>
+/// The exception that is thrown when a QUIC error occurs.
+/// </summary>
+public sealed class QuicException : IOException
{
/// <summary>
- /// The exception that is thrown when a QUIC error occurs.
+ /// Initializes a new instance of the <see cref='QuicException'/> class.
/// </summary>
- public sealed class QuicException : IOException
- {
- /// <summary>
- /// Initializes a new instance of the <see cref='QuicException'/> class.
- /// </summary>
- /// <param name="error">The error associated with the exception.</param>
- /// <param name="applicationErrorCode">The application protocol error code associated with the error.</param>
- /// <param name="message">The message for the exception.</param>
- public QuicException(QuicError error, long? applicationErrorCode, string message)
- : this(error, applicationErrorCode, message, null)
- { }
+ /// <param name="error">The error associated with the exception.</param>
+ /// <param name="applicationErrorCode">The application protocol error code associated with the error.</param>
+ /// <param name="message">The message for the exception.</param>
+ public QuicException(QuicError error, long? applicationErrorCode, string message)
+ : this(error, applicationErrorCode, message, null)
+ { }
- /// <summary>
- /// Initializes a new instance of the <see cref='QuicException'/> class.
- /// </summary>
- /// <param name="error">The error associated with the exception.</param>
- /// <param name="applicationErrorCode">The application protocol error code associated with the error.</param>
- /// <param name="message">The message for the exception.</param>
- /// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
- internal QuicException(QuicError error, long? applicationErrorCode, string message, Exception? innerException)
- : base(message, innerException)
- {
- QuicError = error;
- ApplicationErrorCode = applicationErrorCode;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref='QuicException'/> class.
+ /// </summary>
+ /// <param name="error">The error associated with the exception.</param>
+ /// <param name="applicationErrorCode">The application protocol error code associated with the error.</param>
+ /// <param name="message">The message for the exception.</param>
+ /// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
+ internal QuicException(QuicError error, long? applicationErrorCode, string message, Exception? innerException)
+ : base(message, innerException)
+ {
+ QuicError = error;
+ ApplicationErrorCode = applicationErrorCode;
+ }
- /// <summary>
- /// Gets the error which is associated with this exception.
- /// </summary>
- public QuicError QuicError { get; }
+ /// <summary>
+ /// Gets the error which is associated with this exception.
+ /// </summary>
+ public QuicError QuicError { get; }
- /// <summary>
- /// The application protocol error code associated with the error.
- /// </summary>
- /// <remarks>
- /// This property contains the error code set by the application layer when closing the connection (<see cref="QuicError.ConnectionAborted"/>) or closing a read/write direction of a QUIC stream (<see cref="QuicError.StreamAborted"/>). Contains null for all other errors.
- /// </remarks>
- public long? ApplicationErrorCode { get; }
- }
+ /// <summary>
+ /// The application protocol error code associated with the error.
+ /// </summary>
+ /// <remarks>
+ /// This property contains the error code set by the application layer when closing the connection (<see cref="QuicError.ConnectionAborted"/>) or closing a read/write direction of a QUIC stream (<see cref="QuicError.StreamAborted"/>). Contains null for all other errors.
+ /// </remarks>
+ public long? ApplicationErrorCode { get; }
}