@@ -343,15 +343,39 @@ type LeafParseResult = {
343343 updateTrigger : unknown ;
344344} ;
345345
346+ function describeStyleValue ( value : unknown ) : string {
347+ if ( typeof value === 'string' ) {
348+ return value ;
349+ }
350+ if ( typeof value === 'number' || typeof value === 'boolean' || typeof value === 'undefined' ) {
351+ return String ( value ) ;
352+ }
353+ if ( value === null ) {
354+ return 'null' ;
355+ }
356+ if ( typeof value === 'function' ) {
357+ return value . name ? `[Function ${ value . name } ]` : '[Function]' ;
358+ }
359+ if ( Array . isArray ( value ) ) {
360+ return `[${ value . map ( ( item ) => describeStyleValue ( item ) ) . join ( ', ' ) } ]` ;
361+ }
362+ try {
363+ return JSON . stringify ( value ) ;
364+ } catch {
365+ return String ( value ) ;
366+ }
367+ }
368+
346369/** Parse a non-stateful style value into deck.gl compatible form. */
347370function parseLeafValue ( key : string , value : GraphStyleLeafValue | undefined ) : LeafParseResult {
348371 const formatter = PROPERTY_FORMATTERS [ key ] || IDENTITY ;
349372
350373 if ( typeof value === 'undefined' ) {
351374 const formatted = formatter ( DEFAULT_STYLES [ key ] ) ;
352375 if ( formatted === null ) {
353- log . warn ( `Invalid ${ key } value: ${ value } ` ) ;
354- throw new Error ( `Invalid ${ key } value: ${ value } ` ) ;
376+ const description = describeStyleValue ( value ) ;
377+ log . warn ( `Invalid ${ key } value: ${ description } ` ) ;
378+ throw new Error ( `Invalid ${ key } value: ${ description } ` ) ;
355379 }
356380 return { value : formatted , isAccessor : false , updateTrigger : false } ;
357381 }
@@ -372,8 +396,9 @@ function parseLeafValue(key: string, value: GraphStyleLeafValue | undefined): Le
372396
373397 const formatted = formatter ( value ) ;
374398 if ( formatted === null ) {
375- log . warn ( `Invalid ${ key } value: ${ value } ` ) ;
376- throw new Error ( `Invalid ${ key } value: ${ value } ` ) ;
399+ const description = describeStyleValue ( value ) ;
400+ log . warn ( `Invalid ${ key } value: ${ description } ` ) ;
401+ throw new Error ( `Invalid ${ key } value: ${ description } ` ) ;
377402 }
378403
379404 return { value : formatted , isAccessor : false , updateTrigger : false } ;
0 commit comments