mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 10:04:08 +03:00
Fix error handler
This commit is contained in:
parent
b8b3bf328e
commit
a94afe5f2d
|
@ -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()
|
||||
});
|
||||
})
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user