Class Error
Represents an error that occured when interacting with a Kafka broker or the librdkafka library.
Inherited Members
Namespace: Confluent.Kafka
Assembly: Confluent.Kafka.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. |
string | reason | A custom reason string associated with the error
(overriding the static string associated with
|
Error(ErrorCode, string, bool)
Initialize a new Error instance.
Declaration
public Error(ErrorCode code, string reason, bool isFatal)
Parameters
Type | Name | Description |
---|---|---|
ErrorCode | code | The error code. |
string | reason | The error reason. If null, this will be a static value associated with the error. |
bool | isFatal | Whether or not the error is fatal. |
Exceptions
Type | Condition |
---|---|
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 |
---|---|
bool |
IsError
true if Code != ErrorCode.NoError.
Declaration
public bool IsError { get; }
Property Value
Type | Description |
---|---|
bool |
IsFatal
Whether or not the error is fatal.
Declaration
public bool IsFatal { get; }
Property Value
Type | Description |
---|---|
bool |
IsLocalError
true if this is error originated locally (within librdkafka), false otherwise.
Declaration
public bool IsLocalError { get; }
Property Value
Type | Description |
---|---|
bool |
Reason
Gets a human readable reason string associated with this error.
Declaration
public string Reason { get; }
Property Value
Type | Description |
---|---|
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 |
---|---|---|
object | obj | The object to test. |
Returns
Type | Description |
---|---|
bool | true if obj is an Error and the Code property values are equal. false otherwise. |
Overrides
GetHashCode()
Returns a hash code for this Error value.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | An integer that specifies a hash value for this Error value. |
Overrides
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 |
---|---|
string | A string representation of the Error object. |
Overrides
Operators
operator ==(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 |
---|---|
bool | true if Error values a and b are equal. false otherwise. |
implicit operator ErrorCode(Error)
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 operator Error(ErrorCode)
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 |
operator !=(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 |
---|---|
bool | true if Error values a and b are not equal. false otherwise. |