confluent-kafka-dotnet
Show / Hide Table of Contents

Class Error

Represents an error that occured when interacting with a Kafka broker or the librdkafka library.

Inheritance
System.Object
Error
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Confluent.Kafka
Assembly: cs.temp.dll.dll
Syntax
public class Error

Constructors

Error(Error)

Initialize a new Error instance that is a copy of another.

Declaration
public Error(Error error)
Parameters
Type Name Description
Error error

The error object to initialize from.

Error(ErrorCode)

Initialize a new Error instance from a particular ErrorCode value.

Declaration
public Error(ErrorCode code)
Parameters
Type Name Description
ErrorCode code

The ErrorCode value associated with this Error.

Remarks

The reason string associated with this Error will be a static value associated with the ErrorCode.

Error(ErrorCode, String)

Initialize a new Error instance from a particular ErrorCode value and custom reason string.

Declaration
public Error(ErrorCode code, string reason)
Parameters
Type Name Description
ErrorCode code

The ErrorCode value associated with this Error.

System.String reason

A custom reason string associated with the error (overriding the static string associated with code).

Error(ErrorCode, String, Boolean)

Initialize a new Error instance.

Declaration
public Error(ErrorCode code, string reason, bool isFatal)
Parameters
Type Name Description
ErrorCode code

The error code.

System.String reason

The error reason. If null, this will be a static value associated with the error.

System.Boolean isFatal

Whether or not the error is fatal.

Exceptions
Type Condition
System.ArgumentException

Properties

Code

Gets the ErrorCode associated with this Error.

Declaration
public ErrorCode Code { get; }
Property Value
Type Description
ErrorCode

IsBrokerError

true if this error originated on a broker, false otherwise.

Declaration
public bool IsBrokerError { get; }
Property Value
Type Description
System.Boolean

IsError

true if Code != ErrorCode.NoError.

Declaration
public bool IsError { get; }
Property Value
Type Description
System.Boolean

IsFatal

Whether or not the error is fatal.

Declaration
public bool IsFatal { get; }
Property Value
Type Description
System.Boolean

IsLocalError

true if this is error originated locally (within librdkafka), false otherwise.

Declaration
public bool IsLocalError { get; }
Property Value
Type Description
System.Boolean

Reason

Gets a human readable reason string associated with this error.

Declaration
public string Reason { get; }
Property Value
Type Description
System.String

Methods

Equals(Object)

Tests whether this Error instance is equal to the specified object.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

The object to test.

Returns
Type Description
System.Boolean

true if obj is an Error and the Code property values are equal. false otherwise.

Overrides
System.Object.Equals(System.Object)

GetHashCode()

Returns a hash code for this Error value.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

An integer that specifies a hash value for this Error value.

Overrides
System.Object.GetHashCode()

ToString()

Returns the string representation of the error. Depending on error source this might be a rich contextual error message, or a simple static string representation of the error Code.

Declaration
public override string ToString()
Returns
Type Description
System.String

A string representation of the Error object.

Overrides
System.Object.ToString()

Operators

Equality(Error, Error)

Tests whether Error value a is equal to Error value b.

Declaration
public static bool operator ==(Error a, Error b)
Parameters
Type Name Description
Error a

The first Error value to compare.

Error b

The second Error value to compare.

Returns
Type Description
System.Boolean

true if Error values a and b are equal. false otherwise.

Implicit(Error to ErrorCode)

Converts the specified Error value to the value of it's Code property.

Declaration
public static implicit operator ErrorCode(Error e)
Parameters
Type Name Description
Error e

The Error value to convert.

Returns
Type Description
ErrorCode

Implicit(ErrorCode to Error)

Converts the specified ErrorCode value to it's corresponding rich Error value.

Declaration
public static implicit operator Error(ErrorCode c)
Parameters
Type Name Description
ErrorCode c

The ErrorCode value to convert.

Returns
Type Description
Error

Inequality(Error, Error)

Tests whether Error value a is not equal to Error value b.

Declaration
public static bool operator !=(Error a, Error b)
Parameters
Type Name Description
Error a

The first Error value to compare.

Error b

The second Error value to compare.

Returns
Type Description
System.Boolean

true if Error values a and b are not equal. false otherwise.

In This Article