Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<script src="https://unpkg.com/@reactivex/rxjs@5.0.3/dist/global/Rx.js"></script>
</body>
</html>
 
const throwInMapObs = Rx.Observable.of(null)
  .map(() => {throw new Error('throw Error in .map');})
const throwObs = Rx.Observable.throw(new Error('Observable.throw'))
  
// Handle thrown error in .map
throwInMapObs.subscribe(() => {}, err => console.log('Handle `throw new Error`', err.stack))
try {
  // Do not handle thrown error in .map
  throwInMapObs.subscribe()
} catch (e) {
  console.log('Unhandled error in .map', e.stack)
}
// Handle error thrown with Observable.throw
throwObs.subscribe(() => {}, err => console.log('Handle `Observable.throw`', err.stack))
try {
  // Do not handle error thrown with Observable.throw
  throwObs.subscribe()
} catch (e) {
  console.log('Unhandled error from Observable.throw', e.stack)
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers