Skip to content

Commit

Permalink
fix(error-handler): use translation for action
Browse files Browse the repository at this point in the history
  • Loading branch information
ducktordanny committed Jan 27, 2024
1 parent 46cf52f commit 91427ba
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/frontend/src/app/services/error-handler.service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import {Injectable} from '@angular/core';
import {MatSnackBar} from '@angular/material/snack-bar';

import {TranslateService} from '@ngx-translate/core';
import {EMPTY, Observable} from 'rxjs';

import {APIError} from '../types/api.type';

@Injectable()
export class ErrorHandlerService {
constructor(private snackbar: MatSnackBar) {}
constructor(private snackbar: MatSnackBar, private translateService: TranslateService) {}

public showError = (value: {error: APIError}): Observable<never> => {
const message =
value?.error?.message || value?.error?.error || 'Something went wrong';
this.snackbar.open(message, 'Close');
const message = value?.error?.message || value?.error?.error || 'Something went wrong';
const action = this.translateService.instant('CLOSE');
this.snackbar.open(message, action);
return EMPTY;
};
}

0 comments on commit 91427ba

Please sign in to comment.