Skip to content

Commit

Permalink
Utility: made Retry func take 1 type parameter
Browse files Browse the repository at this point in the history
Changed Retry function to take 1 type parameter instead of 2 as
handling 2 types of exceptions is not needed anymore because
SocketException is wrapped in NOnionException.
  • Loading branch information
webwarrior-ws committed Jan 9, 2023
1 parent 4a052d0 commit 05bd5a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion NOnion/Services/TorServiceHost.fs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ type TorServiceHost
introEncPubKey

do!
FSharpUtil.Retry<SocketException, NOnionException>
FSharpUtil.Retry<NOnionException>
connectToRendezvousJob
maxRendezvousConnectRetryCount

Expand Down
5 changes: 2 additions & 3 deletions NOnion/Utility/FSharpUtil.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module FSharpUtil =
return failwith "unreachable"
}

let Retry<'E1, 'E2 when 'E1 :> Exception and 'E2 :> Exception>
let Retry<'TEx when 'TEx :> Exception>
(jobToRetry: Async<unit>)
(maxRetryCount: int)
=
Expand All @@ -74,8 +74,7 @@ module FSharpUtil =
try
do! jobToRetry
with
| :? 'E1
| :? 'E2 as ex ->
| :? 'TEx as ex ->
if tryNumber < maxRetryCount then
return! retryLoop(tryNumber + 1)
else
Expand Down

0 comments on commit 05bd5a1

Please sign in to comment.