File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ export class LitElement extends BasicElement {
4747 */
4848export { WarningNotice } from './notices/WarningNotice.js' ;
4949export { DeprecationNotice } from './notices/DeprecationNotice.js' ;
50+ export { ErrorThrower } from './notices/ErrorThrower.js' ;
5051
5152/**
5253 * Export events
Original file line number Diff line number Diff line change 1+ export class ErrorThrower {
2+ /**
3+ * Static list to track if any error message has been shown
4+ * across the entire application session
5+ */
6+ private static readonly shownErrors = new Set < string > ( ) ;
7+
8+ /**
9+ * Checks if this error has been shown already
10+ * @param {string } message The error message to check
11+ * @returns {boolean } True if the error has been shown
12+ */
13+ public isShown ( message : string ) : boolean {
14+ return ErrorThrower . shownErrors . has ( message ) ;
15+ }
16+
17+ /**
18+ * Shows the error notice and marks it as shown
19+ * @param {string } message The error message to throw
20+ * @returns {void }
21+ */
22+ public throw ( message : string ) : void {
23+ ErrorThrower . shownErrors . add ( message ) ;
24+ throw new Error ( message ) ;
25+ }
26+
27+ /**
28+ * Shows the error notice only once per application session
29+ * @param {string } message The error message to throw
30+ * @returns {void }
31+ */
32+ public once ( message : string ) : void {
33+ if ( ! this . isShown ( message ) ) {
34+ this . throw ( message ) ;
35+ }
36+ }
37+ }
Original file line number Diff line number Diff line change 44 BasicElement ,
55 CSSResultGroup ,
66 DeprecationNotice ,
7+ ErrorThrower ,
78 PropertyValues ,
89 SVGTemplateResult ,
910 TemplateResult ,
@@ -37,6 +38,8 @@ const EmptyTemplate = svg``;
3738 */
3839export const iconTemplateCache = new Map < string , Promise < SVGTemplateResult > > ( ) ;
3940
41+ const errorThrower = new ErrorThrower ( ) ;
42+
4043@customElement ( 'ef-icon' )
4144export class Icon extends BasicElement {
4245 /**
@@ -230,7 +233,9 @@ export class Icon extends BasicElement {
230233 } else if ( isUrl ( iconProperty ) || IconLoader . isPrefixResolved ) {
231234 void this . loadAndRenderIcon ( iconProperty ) ;
232235 } else {
233- void this . loadAndRenderSpriteIcon ( iconProperty ) ;
236+ void this . loadAndRenderSpriteIcon ( iconProperty ) . catch ( ( error ) => {
237+ errorThrower . once ( String ( error ) ) ;
238+ } ) ;
234239 }
235240 }
236241
You can’t perform that action at this time.
0 commit comments