Fix error handler

This commit is contained in:
Roman Hotsiy 2016-10-31 09:16:39 +02:00
parent b8b3bf328e
commit a94afe5f2d
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 12 additions and 6 deletions

View File

@ -67,7 +67,10 @@ export class Redoc extends BaseComponent implements OnInit {
}
load() {
this.specMgr.load(this.options.specUrl);
this.specMgr.load(this.options.specUrl).catch(err => {
throw err;
});
this.specMgr.spec.subscribe((spec) => {
if (!spec) {
this.specLoading = true;
@ -82,12 +85,15 @@ export class Redoc extends BaseComponent implements OnInit {
ngOnInit() {
this.appState.error.subscribe(_err => {
// do not show errors that occuered after spec has been already loaded
// TODO: change this in future to show in e.g. popup
//if (this.specLoaded) return;
if (!_err) return;
if (this.specLoading) {
this.specLoaded = true;
this.hideLoadingAnimation();
}
this.error = _err;
this.changeDetector.markForCheck();
setTimeout(() => {
this.error = _err;
this.changeDetector.detectChanges()
});
})

View File

@ -7,7 +7,7 @@ export class CustomErrorHandler extends ErrorHandler {
super(true);
}
handleError(error) {
this.appState.error.next(error);
this.appState.error.next(error && error.rejection || error);
super.handleError(error);
}
}