mirror of
https://github.com/Redocly/redoc.git
synced 2025-04-27 12:13:48 +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() {
|
load() {
|
||||||
this.specMgr.load(this.options.specUrl);
|
this.specMgr.load(this.options.specUrl).catch(err => {
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
this.specMgr.spec.subscribe((spec) => {
|
this.specMgr.spec.subscribe((spec) => {
|
||||||
if (!spec) {
|
if (!spec) {
|
||||||
this.specLoading = true;
|
this.specLoading = true;
|
||||||
|
@ -82,12 +85,15 @@ export class Redoc extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.appState.error.subscribe(_err => {
|
this.appState.error.subscribe(_err => {
|
||||||
// do not show errors that occuered after spec has been already loaded
|
if (!_err) return;
|
||||||
// TODO: change this in future to show in e.g. popup
|
|
||||||
//if (this.specLoaded) return;
|
|
||||||
|
|
||||||
setTimeout(() => {
|
if (this.specLoading) {
|
||||||
|
this.specLoaded = true;
|
||||||
|
this.hideLoadingAnimation();
|
||||||
|
}
|
||||||
this.error = _err;
|
this.error = _err;
|
||||||
|
this.changeDetector.markForCheck();
|
||||||
|
setTimeout(() => {
|
||||||
this.changeDetector.detectChanges()
|
this.changeDetector.detectChanges()
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,7 +7,7 @@ export class CustomErrorHandler extends ErrorHandler {
|
||||||
super(true);
|
super(true);
|
||||||
}
|
}
|
||||||
handleError(error) {
|
handleError(error) {
|
||||||
this.appState.error.next(error);
|
this.appState.error.next(error && error.rejection || error);
|
||||||
super.handleError(error);
|
super.handleError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user