aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/error-bar/error-bar.component.ts
blob: 111bac8884017e1b9b7f263373a42ef3fdf35985 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { HttpErrorResponse } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { IApiError } from 'src/interfaces/api-error';

@Component({
  selector: 'app-error-bar',
  templateUrl: './error-bar.component.html',
  styleUrls: ['./error-bar.component.css']
})
export class ErrorBarComponent implements OnInit {
  public errorMsg = '';

  constructor()
  { }

  ngOnInit(): void {
    this.hideError();
  }

  showError(error: HttpErrorResponse): void {
    const test: IApiError = {
      type: '',
      title: 'Error!',
      status: 0,
      traceId: ''
    };
    Object.assign(test, error.error);
    this.errorMsg = test.title;
  }

  hideError(): void {
    this.errorMsg = '';
  }
}