-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: catch errors of wrong use of handlebars #5527
Conversation
✅ Deploy Preview for novu-design ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for dev-web-novu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
const template = Handlebars.compile(templateContent); | ||
|
||
result = template(command.data, {}); | ||
} catch (e: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} catch (e: any) { | |
} catch (e: unknown) { |
Better TS ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it creates a ts error for e.message 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment, thats how all catch errors are typed in the project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ainouzgali You can use checkIsResponseError
as a type-guard here! TypeScript began recommending unknown
as the type for catch
in TS 4.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BiswaViraj Side note: I would suggest that we reserve Request changes
for blocking problems (like issue
or important chore
s) 🙂 -- this is probably more of a nitpick until we put it into a coding style guide
(But agree with commenting on it so we have fewer places to change later 🙌 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Didn't know about it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
…compile' into nv-3772-missing-catch-for-email-compile
I really want to merge it before the next scheduled tests ❤️
* feat: catch errors of wrong use of handlebars * feat: use type guard for error
What changed? Why was the change needed?
For compile email template, there was no catch block for wrong use of handlebars syntax which resulted in
I added the try-catch on the actual template compilation - so we won't miss adding it in each place we are using that usecase.
Sentry links:
1, 2, 3, 4, 5, 6
Screenshots
Expand for optional sections
Related enterprise PR
Special notes for your reviewer