Skip to content

Commit

Permalink
Rather use reraise() instead of raising same captured exception (#1397)
Browse files Browse the repository at this point in the history
This bad practice is equivalent to doing `throw ex;` instead of `throw`
in C#: you lose the original error stack info.
  • Loading branch information
knocte authored Jan 27, 2021
1 parent 6d75fff commit 7b6419a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Fantomas.CoreGlobalTool/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ let main argv =
File.WriteAllText(outFile, File.ReadAllText inFile)
printfn "Force writing original contents to %s" outFile

raise exn
reraise ()

let stringToFile (s: string) (outFile: string) config =
try
Expand All @@ -331,7 +331,7 @@ let main argv =
File.WriteAllText(outFile, s)
printfn "Force writing original contents to %s." outFile

raise exn
reraise ()

let stringToStdOut s config =
try
Expand All @@ -341,7 +341,7 @@ let main argv =
with exn ->
eprintfn "The following exception occurs while formatting stdin: %O" exn
if force then stdout.Write(s)
raise exn
reraise ()

let processFile inputFile outputFile =
if inputFile <> outputFile then
Expand Down Expand Up @@ -382,7 +382,7 @@ let main argv =
if force then
stdout.Write(File.ReadAllText inFile)

raise exn
reraise ()

if Option.isSome version then
let version = CodeFormatter.GetVersion()
Expand Down

0 comments on commit 7b6419a

Please sign in to comment.