Skip to content

Commit 31d3768

Browse files
committed
fix(icon): log full error message when icon set fails to load
Currently when an icon request fails, we log something along the lines of `"Loading icon set URL: {{url}} failed: [object Object]"`. These changes switch to logging out the error message rather than the entire object.
1 parent 1a60a7a commit 31d3768

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
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.log(`Loading icon set URL: ${url} failed: ${err.message}`);
362362
return observableOf(null);
363363
})
364364
);

0 commit comments

Comments
 (0)