fix(icon): log full error message when icon set fails to load (#10915)

This commit is contained in:
Kristiyan Kostadinov
2018-05-04 19:04:37 +02:00
committed by Joey Perrott
parent 28977976e3
commit fbf06bb29b
2 changed files with 8 additions and 8 deletions
+6 -6
View File
@@ -7,7 +7,7 @@
*/
import {DOCUMENT} from '@angular/common';
import {HttpClient} from '@angular/common/http';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {
Inject,
Injectable,
@@ -353,12 +353,12 @@ export class MatIconRegistry {
.filter(iconSetConfig => !iconSetConfig.svgElement)
.map(iconSetConfig => {
return this._loadSvgIconSetFromConfig(iconSetConfig).pipe(
catchError((err: any): Observable<SVGElement | null> => {
let url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);
catchError((err: HttpErrorResponse): Observable<SVGElement | null> => {
const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);
// Swallow errors fetching individual URLs so the combined Observable won't
// necessarily fail.
console.log(`Loading icon set URL: ${url} failed: ${err}`);
// Swallow errors fetching individual URLs so the
// combined Observable won't necessarily fail.
console.error(`Loading icon set URL: ${url} failed: ${err.message}`);
return observableOf(null);
})
);
+2 -2
View File
@@ -428,9 +428,9 @@ describe('MatIcon', () => {
}));
it('should throw an error when using untrusted HTML', () => {
// Stub out console.warn so we don't pollute our logs with Angular's warnings.
// Stub out console.error so we don't pollute our logs with Angular's warnings.
// Jasmine will tear the spy down at the end of the test.
spyOn(console, 'warn');
spyOn(console, 'error');
expect(() => {
iconRegistry.addSvgIconLiteral('circle', '<svg><circle></svg>');