@@ -85,6 +85,17 @@ exception InternalError of message: string * range: range with
85
85
| InternalError ( msg, m) -> msg + m.ToString()
86
86
| _ -> " impossible"
87
87
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
+
88
99
exception UserCompilerMessage of message : string * number : int * range : range
89
100
90
101
exception LibraryUseOnly of range : range
@@ -160,11 +171,11 @@ let rec AttachRange m (exn: exn) =
160
171
else
161
172
match exn with
162
173
// Strip TargetInvocationException wrappers
163
- | :? System.Reflection. TargetInvocationException -> AttachRange m exn.InnerException
174
+ | :? TargetInvocationException -> AttachRange m exn.InnerException
164
175
| UnresolvedReferenceNoRange a -> UnresolvedReferenceError( a, m)
165
176
| 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)
168
179
| _ -> exn
169
180
170
181
type Exiter =
@@ -411,25 +422,12 @@ module DiagnosticsLoggerExtensions =
411
422
Debug.Assert( false , " Could not preserve stack trace for watson exception." )
412
423
()
413
424
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
-
428
425
type DiagnosticsLogger with
429
426
430
427
member x.EmitDiagnostic ( exn , severity ) =
431
428
match exn with
432
429
| InternalError ( s, _)
430
+ | InternalException (_, s, _)
433
431
| Failure s as exn -> Debug.Assert( false , sprintf " Unexpected exception raised in compiler: %s \n %s " s ( exn.ToString()))
434
432
| _ -> ()
435
433
@@ -473,7 +471,6 @@ module DiagnosticsLoggerExtensions =
473
471
| _ ->
474
472
try
475
473
x.ErrorR( AttachRange m exn) // may raise exceptions, e.g. an fsi error sink raises StopProcessing.
476
- ReraiseIfWatsonable exn
477
474
with
478
475
| ReportedError _
479
476
| WrappedError ( ReportedError _, _) -> ()
0 commit comments