import { HttpErrorResponse } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { MatSnackBar } from '@angular/material/snack-bar' ; import { throwError } from 'rxjs' ; import { environment } from '../../environments/environment' ; import { Thumbnail } from './thumbnail.model' ; @ Injectable ( { providedIn : 'root' } ) export class ContextService { copyright = '' ; constructor ( private snackbar ) { } getImage ( variant , thumbnail ) { return `${ thumbnail . path }/${ variant }.${ thumbnail . extension }` ; } handleError = ( error ) => { if ( error . error instanceof ErrorEvent ) { throw error ; } else { this . snackbar . open ( environment . settings . appErrorPrefix + 'Something bad happened; please try again later.' ) ; } return throwError ( error ) ; } ; }