Class DispatchException
- Namespace
- IceRpc
- Assembly
- IceRpc.dll
Represents an exception thrown while dispatching a request. It's encoded as a response with a status code greater than Ok.
public sealed class DispatchException : Exception, ISerializable
- Inheritance
-
DispatchException
- Implements
- Inherited Members
Constructors
DispatchException(StatusCode, string?, Exception?)
Constructs a new instance of DispatchException.
public DispatchException(StatusCode statusCode, string? message = null, Exception? innerException = null)
Parameters
statusCodeStatusCodeThe status code of this exception. It must be greater than Ok.
messagestringA message that describes the exception.
innerExceptionExceptionThe exception that is the cause of the current exception.
Exceptions
- ArgumentOutOfRangeException
Thrown when
statusCodeis equal to Ok.
Properties
ConvertToInternalError
Gets or sets a value indicating whether the exception should be converted into a DispatchException with status code InternalError when thrown from a dispatch.
public bool ConvertToInternalError { get; set; }
Property Value
- bool
When true, this exception is converted into dispatch exception with status code InternalError just before it's encoded. Defaults to true for an exception decoded from an IncomingResponse, and false for an exception created by the application using a constructor of DispatchException.
ErrorMessage
Gets the error message of the failure response that carries this exception.
public string ErrorMessage { get; }
Property Value
- string
The Message of this exception, followed by the type and the message of its InnerException when there is one.
StatusCode
Gets the status code.
public StatusCode StatusCode { get; }
Property Value
- StatusCode
The StatusCode of this exception.
Methods
FromException(Exception)
Converts an exception thrown by a dispatch into a dispatch exception.
public static DispatchException FromException(Exception exception)
Parameters
exceptionExceptionThe exception thrown by the dispatch.
Returns
- DispatchException
exceptionwhen it is a DispatchException with ConvertToInternalError set to false; otherwise, a new dispatch exception withexceptionas its inner exception and a status code that depends on the type ofexception: InvalidData for an InvalidDataException, NotSupported for a NotSupportedException, TruncatedPayload for an IceRpcException with error TruncatedData, and InternalError for any other exception, including a DispatchException with ConvertToInternalError set to true.