From f010b6c1367eaf6510131fce60788e2e49a2cc65 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Tue, 15 Sep 2026 16:32:19 +0200 Subject: [PATCH] Type providers: allow non-RichText errors --- src/Compiler/TypedTree/tainted.fs | 12 +++++++++--- src/Compiler/TypedTree/tainted.fsi | 5 ++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Compiler/TypedTree/tainted.fs b/src/Compiler/TypedTree/tainted.fs index ad0b06857c4..80244a54b1b 100644 --- a/src/Compiler/TypedTree/tainted.fs +++ b/src/Compiler/TypedTree/tainted.fs @@ -33,9 +33,15 @@ type internal TypeProviderError new((errNum, msg: RichText), tpDesignation,m) = TypeProviderError(errNum, tpDesignation, m, [msg]) + new((errNum, msg: string), tpDesignation, m) = + TypeProviderError(errNum, tpDesignation, m, [RichText.mkText msg]) + new(errNum, tpDesignation, m, messages: seq) = TypeProviderError(errNum, tpDesignation, m, List.ofSeq messages, None, None) + new(errNum, tpDesignation, m, messages: seq) = + TypeProviderError(errNum, tpDesignation, m, messages |> Seq.map RichText.mkText |> List.ofSeq, None, None) + member _.Number = errNum member _.Range = m @@ -50,7 +56,7 @@ type internal TypeProviderError override this.Message = this.RichMessage.Text - member _.MapText(f, tpDesignation, m) = + member _.MapText(f: RichText -> int * RichText, tpDesignation, m) = let (errNum: int), _ = f RichText.empty TypeProviderError(errNum, tpDesignation, m, (Seq.map (f >> snd) errors)) @@ -110,11 +116,11 @@ type internal Tainted<'T> (context: TaintedContext, value: 'T) = | :? TypeProviderError -> reraise() | :? AggregateException as ae -> let errNum,_ = FSComp.SR.etProviderError("", "") - let messages = [for e in ae.InnerExceptions -> RichText.mkText (if isNull e.InnerException then e.Message else (e.Message + ": " + e.GetBaseException().Message))] + let messages = [for e in ae.InnerExceptions -> if isNull e.InnerException then e.Message else (e.Message + ": " + e.GetBaseException().Message)] raise <| TypeProviderError(errNum, this.TypeProviderDesignation, range, messages) | e -> let errNum,_ = FSComp.SR.etProviderError("", "") - let error = RichText.mkText (if isNull e.InnerException then e.Message else (e.Message + ": " + e.GetBaseException().Message)) + let error = if isNull e.InnerException then e.Message else (e.Message + ": " + e.GetBaseException().Message) raise <| TypeProviderError((errNum, error), this.TypeProviderDesignation, range) member _.TypeProvider = Tainted<_>(context, context.TypeProvider) diff --git a/src/Compiler/TypedTree/tainted.fsi b/src/Compiler/TypedTree/tainted.fsi index 2a84acb05d2..5f163d2c254 100644 --- a/src/Compiler/TypedTree/tainted.fsi +++ b/src/Compiler/TypedTree/tainted.fsi @@ -21,11 +21,10 @@ type internal TypeProviderLock = type internal TypeProviderError = inherit System.Exception - /// creates new instance of TypeProviderError that represents one error new: (int * RichText) * string * range -> TypeProviderError - - /// creates new instance of TypeProviderError that represents collection of errors + new: (int * string) * string * range -> TypeProviderError new: int * string * range * seq -> TypeProviderError + new: int * string * range * seq -> TypeProviderError member Number: int