Added service for unrecoverable cases
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
48674b1619
commit
58c9b37a4e
|
@ -7,14 +7,16 @@ import {MessageType} from "./model/message-type";
|
|||
providedIn: 'root'
|
||||
})
|
||||
export class MessagesService {
|
||||
private static UNAUTHENTICATED = $localize `You are not logged in which prevents data from loading`;
|
||||
private static UNAUTHORIZED = $localize `You don't have sufficient authorization to view the data`;
|
||||
private static INTERNAL_SERVER_ERROR = $localize `An internal server error occurred. Sorry for the inconvenience.`;
|
||||
private static UNKNOWN_ERROR = $localize `An unknown error occurred. Sorry for the inconvenience.`;
|
||||
private static UNAUTHENTICATED = $localize`You are not logged in which prevents data from loading`;
|
||||
private static UNAUTHORIZED = $localize`You don't have sufficient authorization to view the data`;
|
||||
private static INTERNAL_SERVER_ERROR = $localize`An internal server error occurred. Sorry for the inconvenience.`;
|
||||
private static UNKNOWN_ERROR = $localize`An unknown error occurred. Sorry for the inconvenience.`;
|
||||
private static SERVICE_WORKER_ERROR = $localize`An error with the service worker occurred. Please reload the page.`
|
||||
|
||||
constructor(private store: Store) { }
|
||||
constructor(private store: Store) {
|
||||
}
|
||||
|
||||
logMessage(component: string, type: MessageType) {
|
||||
logMessage(component: string, type: MessageType, details?: string) {
|
||||
let text = component + ": ";
|
||||
switch (type) {
|
||||
case MessageType.UNAUTHENTICATED:
|
||||
|
@ -26,6 +28,12 @@ export class MessagesService {
|
|||
case MessageType.INTERNAL_SERVER_ERROR:
|
||||
text += MessagesService.INTERNAL_SERVER_ERROR;
|
||||
break;
|
||||
case MessageType.SERVICE_WORKER_ERROR:
|
||||
text += MessagesService.SERVICE_WORKER_ERROR;
|
||||
if (details != undefined) {
|
||||
text += "Details: " + details;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
text += MessagesService.UNKNOWN_ERROR;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export enum MessageType {
|
||||
UNAUTHENTICATED,
|
||||
UNAUTHORIZED,
|
||||
INTERNAL_SERVER_ERROR
|
||||
INTERNAL_SERVER_ERROR,
|
||||
SERVICE_WORKER_ERROR
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {SwUpdate} from "@angular/service-worker";
|
||||
import {MessagesService} from "./messages.service";
|
||||
import {MessageType} from "./model/message-type";
|
||||
|
||||
@Injectable()
|
||||
export class ServiceWorkerService {
|
||||
|
||||
constructor(updates: SwUpdate, messages: MessagesService) {
|
||||
updates.unrecoverable.subscribe(event => {
|
||||
messages.logMessage("service-worker", MessageType.SERVICE_WORKER_ERROR, event.reason);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue