Skip to content

Commit fbf06bb

Browse files
crisbetojosephperrott
authored andcommitted
fix(icon): log full error message when icon set fails to load (#10915)
1 parent 2897797 commit fbf06bb

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/lib/icon/icon-registry.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {DOCUMENT} from '@angular/common';
10-
import {HttpClient} from '@angular/common/http';
10+
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
1111
import {
1212
Inject,
1313
Injectable,
@@ -353,12 +353,12 @@ export class MatIconRegistry {
353353
.filter(iconSetConfig => !iconSetConfig.svgElement)
354354
.map(iconSetConfig => {
355355
return this._loadSvgIconSetFromConfig(iconSetConfig).pipe(
356-
catchError((err: any): Observable<SVGElement | null> => {
357-
let url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);
356+
catchError((err: HttpErrorResponse): Observable<SVGElement | null> => {
357+
const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);
358358

359-
// Swallow errors fetching individual URLs so the combined Observable won't
360-
// necessarily fail.
361-
console.log(`Loading icon set URL: ${url} failed: ${err}`);
359+
// Swallow errors fetching individual URLs so the
360+
// combined Observable won't necessarily fail.
361+
console.error(`Loading icon set URL: ${url} failed: ${err.message}`);
362362
return observableOf(null);
363363
})
364364
);

src/lib/icon/icon.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,9 @@ describe('MatIcon', () => {
428428
}));
429429

430430
it('should throw an error when using untrusted HTML', () => {
431-
// Stub out console.warn so we don't pollute our logs with Angular's warnings.
431+
// Stub out console.error so we don't pollute our logs with Angular's warnings.
432432
// Jasmine will tear the spy down at the end of the test.
433-
spyOn(console, 'warn');
433+
spyOn(console, 'error');
434434

435435
expect(() => {
436436
iconRegistry.addSvgIconLiteral('circle', '<svg><circle></svg>');

0 commit comments

Comments
 (0)