diff --git a/src/app/Shared/Services/NotificationChannel.service.tsx b/src/app/Shared/Services/NotificationChannel.service.tsx index 497a4f338..113a0575e 100644 --- a/src/app/Shared/Services/NotificationChannel.service.tsx +++ b/src/app/Shared/Services/NotificationChannel.service.tsx @@ -36,10 +36,10 @@ * SOFTWARE. */ import { Notifications } from '@app/Notifications/Notifications'; -import { BehaviorSubject, combineLatest, from, Observable, Subject } from 'rxjs'; +import { BehaviorSubject, combineLatest, Observable, Subject } from 'rxjs'; import { fromFetch } from 'rxjs/fetch'; import { webSocket, WebSocketSubject } from 'rxjs/webSocket'; -import { concatMap, distinctUntilChanged, filter, map } from 'rxjs/operators'; +import { concatMap, distinctUntilChanged, filter } from 'rxjs/operators'; import { Base64 } from 'js-base64'; import * as _ from 'lodash'; import { ApiService } from './Api.service'; @@ -107,10 +107,18 @@ export class NotificationChannel { const notificationsUrl = fromFetch(`${this.apiSvc.authority}/api/v1/notifications_url`) .pipe( - concatMap(resp => from(resp.json())), - map((url: any): string => url.notificationsUrl) + concatMap(async resp => { + if (resp.ok) { + let body: any = await resp.json(); + return body.notificationsUrl; + } else { + let body: string = await resp.text(); + throw new Error(resp.status + ' ' + body); + } + }) ); - combineLatest([notificationsUrl, this.apiSvc.getToken(), this.apiSvc.getAuthMethod()]) + + combineLatest(notificationsUrl, this.apiSvc.getToken(), this.apiSvc.getAuthMethod()) .pipe(distinctUntilChanged(_.isEqual)) .subscribe({ next: (parts: string[]) => { @@ -184,8 +192,8 @@ export class NotificationChannel { } private logError(title: string, err: any): void { - window.console.error(err); - this.notifications.danger(title, JSON.stringify(err)); + window.console.error(err.stack); + this.notifications.danger(title, JSON.stringify(err.message)); } }