Skip to content

Commit

Permalink
chore(icon): improve icon load error message (#11367)
Browse files Browse the repository at this point in the history
**Related Issue:** N/A

## Summary

This improves clarity by displaying the icon name and scale separately
in the error message instead of an internal key used by icon utils:

```sh
"measure16" is not a valid calcite-ui-icon name
```

⬇️

```sh
measure (s) icon failed to load.
```

Also, this now uses the logger to display the `calcite` badge for
additional context.
  • Loading branch information
jcfranco authored Jan 23, 2025
1 parent b39b8ae commit 62f2ef2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/calcite-components/src/components/icon/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CalciteIconPath } from "@esri/calcite-ui-icons";
import { Scale } from "../interfaces";
import { getAssetPath } from "../../runtime";
import { logger } from "../../utils/logger";
import { IconNameOrString } from "./interfaces";

export interface FetchIconProps {
Expand Down Expand Up @@ -51,7 +52,7 @@ export async function fetchIcon(props: FetchIconProps): Promise<CalciteIconPath>
requestCache[cachedIconKey] = fetch(getAssetPath(`./assets/icon/${cachedIconKey}.json`))
.then((resp) => resp.json())
.catch(() => {
console.error(`"${cachedIconKey}" is not a valid calcite-ui-icon name`);
logger.error(`${props.icon} (${props.scale}) icon failed to load`);
return "";
});
}
Expand Down

0 comments on commit 62f2ef2

Please sign in to comment.