Skip to content
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: add try-catch block to custom logger for js files #267

Merged
merged 3 commits into from
Sep 3, 2020

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Sep 3, 2020

JavaScript files will not throw any error when the wrong argument signature is passed into logger invocations. Add try catch block as a defensive measure at least until the application is 100% typescript, to prevent possible errors from being thrown due to the wrong type

JavaScript files will not throw any error when the wrong argument signature is passed into logger invocations. Add try catch block as a defensive measure at least until the application is 100% typescript, to prevent possible errors from being thrown due to the wrong type
Copy link
Contributor

@tshuli tshuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed that if a string is passed into logger, it will be destructured into undefined instead of throwing an error, and the log message will be lost. This is an existing issue with the code. Suggested some changes since we are taking this chance to review. lgtm otherwise!

src/config/logger.ts Show resolved Hide resolved
src/config/logger.ts Show resolved Hide resolved
src/config/logger.ts Show resolved Hide resolved
@karrui
Copy link
Contributor Author

karrui commented Sep 3, 2020

Throw error on shape mismatch instead, pls rereview

@karrui karrui requested a review from tshuli September 3, 2020 09:43
src/config/logger.ts Outdated Show resolved Hide resolved
Co-authored-by: Antariksh Mahajan <antarikshmahajan@gmail.com>
@karrui karrui merged commit d19a105 into develop Sep 3, 2020
@karrui karrui deleted the refactor/defensive-logger branch September 3, 2020 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants