Table of Contents

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

statusCode StatusCode

The status code of this exception. It must be greater than Ok.

message string

A message that describes the exception.

innerException Exception

The exception that is the cause of the current exception.

Exceptions

ArgumentOutOfRangeException

Thrown when statusCode is 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

exception Exception

The exception thrown by the dispatch.

Returns

DispatchException

exception when it is a DispatchException with ConvertToInternalError set to false; otherwise, a new dispatch exception with exception as its inner exception and a status code that depends on the type of exception: 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.