From a94afe5f2d742a9e1b2e2b1f004fe813db69138f Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 31 Oct 2016 09:16:39 +0200 Subject: [PATCH] Fix error handler --- lib/components/Redoc/redoc.ts | 16 +++++++++++----- lib/utils/custom-error-handler.ts | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/components/Redoc/redoc.ts b/lib/components/Redoc/redoc.ts index 93d76b36..56f72601 100644 --- a/lib/components/Redoc/redoc.ts +++ b/lib/components/Redoc/redoc.ts @@ -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() }); }) diff --git a/lib/utils/custom-error-handler.ts b/lib/utils/custom-error-handler.ts index 7df0e7f9..b5cd6fe4 100644 --- a/lib/utils/custom-error-handler.ts +++ b/lib/utils/custom-error-handler.ts @@ -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); } }