How to throw an observable error manually? How to throw an observable error manually? typescript typescript

How to throw an observable error manually?


if (response.success == 0) {   throw Observable.throw(response);   } 

Edit for rxjs 6:

if (response.success == 0) {   throw throwError(response);   } 


rxjs 6

import { throwError } from 'rxjs';if (response.success == 0) {  return throwError(response);  }

rxjs 5

import { ErrorObservable } from 'rxjs/observable/ErrorObservable';if (response.success == 0) {  return new ErrorObservable(response);  }

What you return with ErrorObservable is up to you


with rxjs 6

import { throwError } from 'rxjs';throwError('hello');