Läs på engelska Redigera

Dela via


IObserver<T>.OnError(Exception) Method

Definition

Notifies the observer that the provider has experienced an error condition.

public void OnError(Exception error);

Parameters

error
Exception

An object that provides additional information about the error.

Examples

The following example provides an implementation of the OnError method in a latitude/longitude tracking application. The method simply reports that data is currently unavailable; it does not make use of the Exception object passed to it as a parameter. See the Example section of the IObserver<T> topic for the complete example.

public virtual void OnError(Exception e)
{
   Console.WriteLine("{0}: The location cannot be determined.", this.Name);
}

Remarks

Although error is an object that is derived from System.Exception, it does not necessarily represent an exception that is thrown by the provider. It can also represent a routine or expected error condition, such as data that is missing or unavailable. The OnError method should be seen as informational, and the provider should not expect the observer to provide error handling.

Applies to

Produkt Versioner
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

See also