korbit-ai[bot] commented on code in PR #33143:
URL: https://github.com/apache/superset/pull/33143#discussion_r2045849494
##########
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx:
##########
@@ -106,6 +107,15 @@ use([
LabelLayout,
]);
+const loadLocale = async (locale: string) => {
+ try {
+ const lang = await import(`echarts/lib/i18n/lang${locale}`);
+ return lang?.default;
+ } catch (e) {
+ console.error(`Locale ${locale} not supported in ECharts`, e);
Review Comment:
### Unstructured console.error usage <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
Using console.error for error logging instead of a proper logging framework.
Also, the error object 'e' is directly passed without structure.
###### Why this matters
Console.error logs are not captured by logging infrastructure, making it
difficult to monitor and track locale loading failures in production
environments.
###### Suggested change ∙ *Feature Preview*
```typescript
const loadLocale = async (locale: string) => {
try {
const lang = await import(`echarts/lib/i18n/lang${locale}`);
return lang?.default;
} catch (error) {
logger.error('Failed to load ECharts locale', {
locale,
error: {
message: error.message,
stack: error.stack,
},
component: 'Echart'
});
}
};
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/fd4ac080-169a-4528-b2cc-b06c68f6c4c8/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/fd4ac080-169a-4528-b2cc-b06c68f6c4c8?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/fd4ac080-169a-4528-b2cc-b06c68f6c4c8?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/fd4ac080-169a-4528-b2cc-b06c68f6c4c8?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/fd4ac080-169a-4528-b2cc-b06c68f6c4c8)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:bfba0f39-7687-4567-a237-fca2d1bfbfa6 -->
[](bfba0f39-7687-4567-a237-fca2d1bfbfa6)
##########
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx:
##########
@@ -106,6 +107,15 @@
LabelLayout,
]);
+const loadLocale = async (locale: string) => {
+ try {
+ const lang = await import(`echarts/lib/i18n/lang${locale}`);
+ return lang?.default;
+ } catch (e) {
+ console.error(`Locale ${locale} not supported in ECharts`, e);
+ }
+};
Review Comment:
### Tightly coupled locale loading <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The locale loading logic is tightly coupled with the ECharts implementation
and error handling is incomplete.
###### Why this matters
Makes it difficult to change locale loading strategy or handle errors
properly at the application level. The function also doesn't follow the
Interface Segregation Principle by mixing concerns.
###### Suggested change ∙ *Feature Preview*
Create a separate locale service with proper error handling:
```typescript
interface LocaleLoader {
loadLocale(locale: string): Promise<any>;
}
class EchartsLocaleLoader implements LocaleLoader {
async loadLocale(locale: string): Promise<any> {
try {
const lang = await import(`echarts/lib/i18n/lang${locale}`);
return lang?.default;
} catch (error) {
throw new LocaleLoadError(locale, error);
}
}
}
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/70239cc4-1c45-4feb-9d71-25f3b33a71ba/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/70239cc4-1c45-4feb-9d71-25f3b33a71ba?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/70239cc4-1c45-4feb-9d71-25f3b33a71ba?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/70239cc4-1c45-4feb-9d71-25f3b33a71ba?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/70239cc4-1c45-4feb-9d71-25f3b33a71ba)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:988999b9-db70-4a45-9956-9dee7f269704 -->
[](988999b9-db70-4a45-9956-9dee7f269704)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]