blob: ee85fd32ce68e097dc60a9b660eaf03858c92346 [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2015-2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
import { ErrorHandler, Injectable, OnInit } from '@angular/core';
import { MDMNotificationService } from './mdm-notification.service';
import { TranslateService } from '@ngx-translate/core';
import { streamTranslate, TRANSLATE } from '../core/mdm-core.module';
@Injectable()
export class MDMErrorHandler extends ErrorHandler implements OnInit {
msgsError: string = 'Application Error$An application error has occurred.'
+ ' For a detailed error message please open your browser\'s developer console.';
constructor(private notificationService: MDMNotificationService,
private translateService: TranslateService) {
super();
}
ngOnInit() {
streamTranslate(this.translateService, TRANSLATE('core.mdm-error-handler.strings-error-message')).subscribe(
(msg: string) => this.msgsError = msg);
}
handleError(error) {
this.notificationService.notifyError(this.msgsError.split('$')[0],
this.msgsError.split('$')[1]);
super.handleError(error);
}
}