cartant / rxjs-spy

A debugging library for RxJS
https://cartant.github.io/rxjs-spy/
MIT License
702 stars 22 forks source link

"Value passed as error notification is not an Error instance = ..." #18

Closed trevorchunestudy closed 6 years ago

trevorchunestudy commented 6 years ago

What would cause the error from spy-core.js-327?

"Value passed as error notification is not an Error instance = ..."

The only thing I have configured in my Angular app is importing 'create' and setting const of spy = create(); in my main.ts file per the github instructions.

cartant commented 6 years ago

It's not an error; it's a warning.

rxjs-spy sees all notifications received by all subscribers that subscribe after create has been called. If it sees a value passed as an error notification that is not an Error or an Error-derived class, it outputs the warning.

If you are seeing the warning, you either have code that throws non-Error values, code that passes non-Error values to an observer's error method, or code that passes non-Error values to Observable.throw.

trevorchunestudy commented 6 years ago

My bad it is a warning. Thank you for the explanation. That makes sense. `

m-radzikowski commented 6 years ago

@cartant I agree with you about general idea of using Error-derived classes. But Angular itself uses NoMatch class in routing: https://github.com/angular/angular/blob/6.1.x/packages/router/src/apply_redirects.ts#L31

This results in a console full of warnings just because using routing in Angular app. This is irritating as it's makes valuable logs and warnings much harder to spot.

How do you feel about for example adding parameter to library that would disable printing warnings?

cartant commented 6 years ago

@m-radzikowski Fair enough. I'll see what I can do to limit the number of warnings, so that you're warned only once for each error call. And if that's not possible, I'll make this configurable.

cartant commented 6 years ago

@m-radzikowski I've changed my mind and I've removed the warning completely. The passing of non-Error values in error notifications (in user code) would be better prevented using linting rules (see the entry in the CHANGELOG).

The logging should be removed in 7.2.1.

m-radzikowski commented 6 years ago

@cartant thanks for so quick response and new release. You are doing a great job!

I didn't know the rxjs-tslint-rules, i will definately try them too!