Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

IObserver<T>.OnError(Exception) Method

Definition

Namespace:
System
Assemblies:
mscorlib.dll, System.Runtime.dll
Assemblies:
netstandard.dll, System.Runtime.dll
Assembly:
System.Runtime.dll
Assembly:
mscorlib.dll
Assembly:
netstandard.dll
Source:
IObserver.cs
Source:
IObserver.cs
Source:
ThreadPoolBoundHandle.Unix.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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

public:
 void OnError(Exception ^ error);
public void OnError(Exception error);
abstract member OnError : Exception -> unit
Public Sub OnError (error As Exception)

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);
}
member _.OnError(_) =
 printfn $"{name}: The location cannot be determined."
Public Overridable Sub OnError(ByVal e As System.Exception) Implements System.IObserver(Of Location).OnError
 Console.WriteLine("{0}: The location cannot be determined.", Me.Name)
End Sub

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

See also


Feedback

Was this page helpful?