From b4357e8e3e84b33880230b7c7311e37e952bf840 Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Wed, 27 Feb 2019 15:04:37 -0700 Subject: [PATCH] added message handling in error --- .../provider/effect/collection.effect.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ui/src/app/metadata/provider/effect/collection.effect.ts b/ui/src/app/metadata/provider/effect/collection.effect.ts index c0a421188..2a521a501 100644 --- a/ui/src/app/metadata/provider/effect/collection.effect.ts +++ b/ui/src/app/metadata/provider/effect/collection.effect.ts @@ -101,7 +101,9 @@ export class CollectionEffects { .save(provider) .pipe( map(p => new AddProviderSuccess(p)), - catchError((e) => of(new AddProviderFail(e.error))) + catchError((e) => { + return of(new AddProviderFail(e.error)); + }) ) ) ); @@ -111,13 +113,17 @@ export class CollectionEffects { ofType(ProviderCollectionActionTypes.ADD_PROVIDER_FAIL), map(action => action.payload), withLatestFrom(this.store.select(fromI18n.getMessages)), - map(([error, messages]) => new AddNotification( - new Notification( - NotificationType.Danger, - `${error.errorCode}: ${ this.i18nService.translate(error.errorMessage, null, messages) }`, - 8000 - ) - )) + map(([error, messages]) => { + let message = `${error.errorCode}: ${this.i18nService.translate(error.errorMessage, null, messages)}`; + message = error.cause ? `${message} - ${error.cause}` : message; + return new AddNotification( + new Notification( + NotificationType.Danger, + message, + 8000 + ) + ); + }) ); @Effect() createProviderFailEnableForm$ = this.actions$.pipe(