-
-
Notifications
You must be signed in to change notification settings - Fork 873
Closed
Labels
enhancementNew feature or request.New feature or request.
Description
What is the feature you are proposing?
getContext is definitely useful right now, but only in the context of a request.
I'm guessing that one of its most popular uses is in a logging function -- but those can be called outside of a request context too, and then it throws an error. Using a try/catch is both extra runtime baggage and extra verbiage.
It would be simpler -- for such cases -- if it simply didn't throw the error.
Changing its type would most likely be problematic for existing code, and adding some flag to contextStorage would be ugly. So, a simpler solution is to add some new getContextIfAny which would be the same as getContext except for not throwing the error (so, a quick one-liner).
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request.New feature or request.