Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Angular2, suppress chrome console errors for image not found

Tags:

angular

In Angular2, suppress chrome console errors for image not found

so I have this code:

<div *ngIf="defaultImage"> 
          <img [ngStyle]="_style.img" [ngClass]="{'img-circle': circle}" [src]="getImageUrl()" (load)="onImageLoaded()" (error)="onImageError()" />
 </div>

so I have this function that looks for images online, and if an image is not found I catch the error and take action. However I am seeing an annoying console error which I would like to suppress when I am developing as its just of an annoyance, is it possible?

see below: enter image description here

regards

Sean

like image 846
born2net Avatar asked Jun 06 '16 18:06

born2net


1 Answers

There is no way to suppress this error. This is browser default behavior.

If your server provides an API where you can query in advance if the file exists, that could be done. That check must not result in a 404 in case the image doesn't exist, or the check would just result in the same console log output.

like image 189
Günter Zöchbauer Avatar answered Oct 09 '22 22:10

Günter Zöchbauer