Skip to content

Commit

Permalink
added message handling in error
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Feb 27, 2019
1 parent 46a291d commit b4357e8
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions ui/src/app/metadata/provider/effect/collection.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
})
)
)
);
Expand All @@ -111,13 +113,17 @@ export class CollectionEffects {
ofType<AddProviderFail>(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(
Expand Down

0 comments on commit b4357e8

Please sign in to comment.