korbit-ai[bot] commented on code in PR #31998:
URL: https://github.com/apache/superset/pull/31998#discussion_r1930319717
##########
superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx:
##########
@@ -99,5 +99,14 @@ Handlebars.registerHelper(
},
);
+// usage: {{parseJson jsonString}}
+Handlebars.registerHelper('parseJson', (jsonString: string) => {
+ try {
+ return JSON.parse(jsonString);
+ } catch (error) {
+ throw new Error(`Invalid JSON string: ${error.message}`);
+ }
Review Comment:
### Loss of Original Error Context <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The parseJson helper wraps the original error, losing the original error
type and stack trace.
###### Why this matters
Wrapping errors without preserving the original error context makes
debugging more challenging.
###### Suggested change ∙ *Feature Preview*
```typescript
catch (error) {
if (error instanceof Error) {
error.message = `Invalid JSON string: ${error.message}`;
throw error;
}
throw new Error(`Invalid JSON string: ${String(error)}`);
}
```
</details>
<sub>💡 Does this comment miss the mark? [Tell us
why](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/bca3cf16-134c-4fc9-b9a3-a9ba45c44e86?suggestedFixEnabled=true)
and Korbit will adapt to your team’s feedback.
💬 Chat with Korbit by mentioning @korbit-ai.
</sub>
<!--- korbi internal id:e872f7f2-4fbe-499b-b941-99f39bcb126b -->
--
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]