Consolidate McpClientException/McpServerException into McpException (#209)
This commit is contained in:
parent
d1a3c201a4
commit
8fcdf95785
1 changed files with 163 additions and 197 deletions
56
src/ModelContextProtocol/McpException.cs
Normal file
56
src/ModelContextProtocol/McpException.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
namespace ModelContextProtocol;
|
||||
|
||||
/// <summary>
|
||||
/// An exception that is thrown when an MCP configuration or protocol error occurs.
|
||||
/// </summary>
|
||||
public class McpException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="McpException"/> class.
|
||||
/// </summary>
|
||||
public McpException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="McpException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public McpException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="McpException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</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>
|
||||
public McpException(string message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="McpException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
/// <param name="errorCode">A JSON-RPC error code, if this exception represents a JSON-RPC error.</param>
|
||||
public McpException(string message, int? errorCode) : this(message, null, errorCode)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="McpException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</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>
|
||||
/// <param name="errorCode">A JSON-RPC error code, if this exception represents a JSON-RPC error.</param>
|
||||
public McpException(string message, Exception? innerException, int? errorCode) : base(message, innerException)
|
||||
{
|
||||
ErrorCode = errorCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the error code if this exception was caused by a JSON-RPC error response.
|
||||
/// </summary>
|
||||
public int? ErrorCode { get; }
|
||||
}
|
||||
Loading…
Reference in a new issue