Skip to content

Commit

Permalink
feat(alert-service): log an error and display a message
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximBalaganskiy committed Jul 31, 2019
1 parent 557762f commit 3144e76
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/services/alert-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { ProgressHandle } from "./progress-handle";
import { IDisposable } from "../interfaces/i-disposable";
import { AlertModal } from "../elements/alert-modal/alert-modal";
import { I18NResource } from "../interfaces/i18n-resource";
import { ApplicationInsights } from "@microsoft/applicationinsights-web";

@au.autoinject
export class AlertService {
constructor(private toast: au.MdToastService, private eventAggregator: au.EventAggregator, private templatingEngine: au.TemplatingEngine,
private i18n: au.I18N) {
private i18n: au.I18N, private appInsights: ApplicationInsights) {
this.logger = au.getLogger("AlertService");
this.i18nResource = this.i18n.tr("aurelia-toolkit:alert", { returnObjects: true }) as any as I18NResource["alert"];
}
Expand Down Expand Up @@ -52,6 +53,11 @@ export class AlertService {
return this.alert(message, "error", "red");
}

criticalError(message: string, error: any): Promise<boolean> {
this.appInsights.trackException(error);
return this.alert(message, "error", "red");
}

confirmToast(message: string, timeout?: number) {
this.toast.show(message as any, timeout || this.defaultTimeout);
}
Expand Down

0 comments on commit 3144e76

Please sign in to comment.