-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
[Fix]: 🐛 Strapi parser middleware, catch block error logging #9612
[Fix]: 🐛 Strapi parser middleware, catch block error logging #9612
Conversation
Throwing error inside of a controller (using plain javascript) results in a different error in parser middleware. Before calling methods on the `message` pr operty on the error object a check should be performed to see if the `message` property is defined on the error instance. ✅ Closes: strapi#9356
Codecov Report
@@ Coverage Diff @@
## master #9612 +/- ##
=======================================
Coverage 35.98% 35.98%
=======================================
Files 1337 1337
Lines 14768 14768
Branches 1475 1475
=======================================
Hits 5314 5314
Misses 8536 8536
Partials 918 918
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
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.
Thanks for the improvement
What does it do?
Throwing error inside of a controller (using plain javascript) results in a different error in parser middleware.
Before calling (
String.prototype.includes
) method on themessage
property on the error object, a check should be performed to see if themessage
property is defined on the error instance so no runtimeTypeError
is thrown.Why is it needed?
Throw statements from within the code resulted in a
TypeError
with stack trace leading toStrapi
parser middleware.Instead, error logging should have appropriate stack trace from within the file where the error is thrown from.
How to test it?
Reference: #9356 (comment)
Related issue(s)/PR(s)
Related issue: #9356
Additional notes?
No new test cases are provided. Even though this is a trivial change (and is just a safeguard from the runtime
TypeError
), I would be willing to provide new test cases but I would need some assistance of where those should be placed and how can this be thoroughly tested.attn. @alexandrebodin @Convly