Get current .Position outside of a shortcode

For shortcodes we have the .Position variable, that gives us access to the location (file/line) of the call to the shortcode. Is there anything similar to this outside of a shortcode layout? It would be helpful if we could add a location to errorf/warnf calls somehow.