2016-10-23 20:18:42 +03:00
|
|
|
import { ErrorHandler, Injectable } from '@angular/core';
|
|
|
|
import { AppStateService } from '../services/app-state.service';
|
|
|
|
|
|
|
|
@Injectable()
|
2016-10-30 18:54:44 +03:00
|
|
|
export class CustomErrorHandler extends ErrorHandler {
|
2016-10-23 20:18:42 +03:00
|
|
|
constructor(private appState: AppStateService) {
|
2016-10-30 18:54:44 +03:00
|
|
|
super(true);
|
2016-10-23 20:18:42 +03:00
|
|
|
}
|
|
|
|
handleError(error) {
|
2016-10-31 10:16:39 +03:00
|
|
|
this.appState.error.next(error && error.rejection || error);
|
2016-10-30 18:54:44 +03:00
|
|
|
super.handleError(error);
|
2016-10-23 20:18:42 +03:00
|
|
|
}
|
|
|
|
}
|