using ModelContextProtocol.Client;
namespace ModelContextProtocol.Server;
///
/// Represents errors that occur in the MCP server.
///
public class McpServerException : Exception
{
///
/// Gets the error code if this exception was caused by a JSON-RPC error response.
///
public int? ErrorCode { get; }
///
/// Initializes a new instance of the class with a specified error message.
///
public McpServerException()
{
}
///
/// Initializes a new instance of the class with a specified error message.
///
/// The message that describes the error.
public McpServerException(string message) : base(message)
{
}
///
/// Initializes a new instance of the class with a specified error message and error code.
///
/// The message that describes the error.
/// The error code associated with the JSON-RPC error response.
public McpServerException(string message, int errorCode) : base(message)
{
ErrorCode = errorCode;
}
///
/// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
///
/// The message that describes the error.
/// The exception that is the cause of the current exception, or a null reference if no inner exception is specified.
public McpServerException(string message, Exception innerException) : base(message, innerException)
{
}
}