console . log ( `catch_error.ts` ) ; import { of , Observable } from "rxjs" ; import { map , catchError } from "rxjs/operators" ; interface IValue { value : number ; } interface INestedObj { id ? : IValue ; } const objEmit = of ( { id : { value : 1 } } , { } , { id : { value : 2 } } ) ; const returnIdValue = objEmit . pipe ( map ( ( value ) => { return value . id ! . value ; } ) , catchError ( ( error ) => { console . log ( `stream caught : ${ error }` ) ; return of ( null ) ; } ) ) ; returnIdValue . subscribe ( ( value ) => { console . log ( `received ${ value } ` ) ; } , ( error ) => { console . log ( `error : ${ error }` ) ; } , ( ) => { console . log ( `complete` ) ; } ) ;