Allow TypeProviders to supply location with errors
When a custom type provider fails, the type provider will typically throw, there is not much else to do.
I suggest to add the ability to add an error location when something fails. This would allow to pinpoint with squigglies where the error is in ie json/sql/whatever.
Perhaps the simplest non-breaking implementation would be to add a known exception type that contains a file location and a range. So the TP still just throws, but adds this information where possible.
Approved in principle for F# 4.0 (or later, depending), along with “allow type providers to report warnings”. subject to a suitable implementation being submitted. Both are entirely reasonable
Implementations of approved language design items can now be submitted as pull requests to the appropriate branch of http://github.com/Microsoft/visualfsharp. See http://fsharp.github.io/2014/06/18/fsharp-contributions.html for information on contributing to the F# language and core library.
Don Syme, F# Language/Library evolution
See also this proposal https://fslang.uservoice.com/forums/245727-f-language/suggestions/5663288-allow-type-providers-to-report-warnings-to-the-com, these should probably be combined