Class SessionException
- Namespace
- VpnHood.Core.Common.Exceptions
- Assembly
- VpnHood.Core.Common.dll
The exception that is thrown when a server answers a session's request with an error, or a session ends with one.
public class SessionException : Exception, ISerializable
- Inheritance
-
SessionException
- Implements
- Derived
- Inherited Members
Remarks
The first two constructors put the response, as JSON, its error code and its SuppressedBy in the exception's Data, so an API error made of it can be turned back into it; the API error's constructor does not.
Constructors
SessionException(SessionErrorCode, string?)
Initializes a new instance of the SessionException class with an error code.
public SessionException(SessionErrorCode errorCode, string? message = null)
Parameters
errorCodeSessionErrorCodeThe error code.
messagestringThe message, or null for the error code's standard one.
SessionException(SessionResponse)
Initializes a new instance of the SessionException class with a server's response.
public SessionException(SessionResponse sessionResponse)
Parameters
sessionResponseSessionResponseThe response, whose message is the exception's; a response with no message is given its error code's standard one.
SessionException(ApiError)
Initializes a new instance of the SessionException class from an API error that a SessionException became, with the response its data carries.
public SessionException(ApiError apiError)
Parameters
apiErrorApiErrorThe API error.
Exceptions
- ArgumentException
The API error is not one of a SessionException, or carries no response.
- JsonException
The response in the error's data is not valid JSON.
- FormatException
An endpoint in the response is not valid.
Properties
SessionResponse
Gets the server's response.
public SessionResponse SessionResponse { get; }