-
Notifications
You must be signed in to change notification settings - Fork 8
catchError
richardszalay edited this page May 20, 2011
·
6 revisions
Runs a specific sequence when an error occurs, and prevents the original error message from being emitted
function catchError(second : IObservable.<T>) : IObservable.<T>
Where second is the observable sequence to subscribe to when an error in the source sequence occurs.
The returned sequence completes when the source sequence completes.
The returned sequence errors if an error occurs in the second sequence and an error occurs in second.
xs ──o─────o─────x
│ │ │
other │ │ └─o─o─/
│ │ │ │ │
ys ──o─────o───────o─o─/
xs ──o─────o─────x
│ │ │
other │ │ └─x
│ │ │
ys ──o─────o───────x
xs ──o─────o─────/
│ │ │
other │ │ │
│ │ │
ys ──o─────o─────/
IObservable.<T>
Observable.error(new Error())
.catchError(toObservable([1, 2, 3]))
.subscribe(
function(x:int) : void { trace(x); },
function() : void { trace("Completed"); },
function(e:Error) : void { trace("Error: " + e.message); }
);
// Trace output is:
// 1
// 2
// 3
// Completed