@@ -85,6 +85,17 @@ exception InternalError of message: string * range: range with
8585 | InternalError ( msg, m) -> msg + m.ToString()
8686 | _ -> " impossible"
8787
88+ exception InternalException of exn : Exception * msg : string * range : range with
89+ override this.Message =
90+ match this :> exn with
91+ | InternalException (_, msg, _) -> msg
92+ | _ -> " impossible"
93+
94+ override this.ToString () =
95+ match this :> exn with
96+ | InternalException ( exn, _, _) -> exn.ToString()
97+ | _ -> " impossible"
98+
8899exception UserCompilerMessage of message : string * number : int * range : range
89100
90101exception LibraryUseOnly of range : range
@@ -160,11 +171,11 @@ let rec AttachRange m (exn: exn) =
160171 else
161172 match exn with
162173 // Strip TargetInvocationException wrappers
163- | :? System.Reflection. TargetInvocationException -> AttachRange m exn.InnerException
174+ | :? TargetInvocationException -> AttachRange m exn.InnerException
164175 | UnresolvedReferenceNoRange a -> UnresolvedReferenceError( a, m)
165176 | UnresolvedPathReferenceNoRange ( a, p) -> UnresolvedPathReference( a, p, m)
166- | Failure msg -> InternalError ( msg + " (Failure) " , m )
167- | :? ArgumentException as exn -> InternalError ( exn.Message + " (ArgumentException) " , m)
177+ | :? NotSupportedException -> exn
178+ | :? SystemException -> InternalException ( exn, exn .Message, m)
168179 | _ -> exn
169180
170181type Exiter =
@@ -411,25 +422,12 @@ module DiagnosticsLoggerExtensions =
411422 Debug.Assert( false , " Could not preserve stack trace for watson exception." )
412423 ()
413424
414- /// Reraise an exception if it is one we want to report to Watson.
415- let ReraiseIfWatsonable ( exn : exn ) =
416- match exn with
417- // These few SystemExceptions which we don't report to Watson are because we handle these in some way in Build.fs
418- | :? TargetInvocationException -> ()
419- | :? NotSupportedException -> ()
420- | :? System.IO.IOException -> () // This covers FileNotFoundException and DirectoryNotFoundException
421- | :? UnauthorizedAccessException -> ()
422- | Failure _ // This gives reports for compiler INTERNAL ERRORs
423- | :? SystemException ->
424- PreserveStackTrace exn
425- raise exn
426- | _ -> ()
427-
428425 type DiagnosticsLogger with
429426
430427 member x.EmitDiagnostic ( exn , severity ) =
431428 match exn with
432429 | InternalError ( s, _)
430+ | InternalException (_, s, _)
433431 | Failure s as exn -> Debug.Assert( false , sprintf " Unexpected exception raised in compiler: %s \n %s " s ( exn.ToString()))
434432 | _ -> ()
435433
@@ -473,7 +471,6 @@ module DiagnosticsLoggerExtensions =
473471 | _ ->
474472 try
475473 x.ErrorR( AttachRange m exn) // may raise exceptions, e.g. an fsi error sink raises StopProcessing.
476- ReraiseIfWatsonable exn
477474 with
478475 | ReportedError _
479476 | WrappedError ( ReportedError _, _) -> ()
0 commit comments