Skip to content

Commit

Permalink
Safer exn cast on Push error
Browse files Browse the repository at this point in the history
  • Loading branch information
varon committed Nov 22, 2016
1 parent 20d2c36 commit 09ed8d5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Paket.Core/RemoteUpload.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ let Push maxTrials url apiKey packageFileName =
failwithf "Package %s already exists." packageFileName
| exn when trial < maxTrials ->
if exn.Message.Contains("(409)") |> not then // exclude conflicts
let response = (exn :?> System.Net.WebException).Response
use reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)
let text = reader.ReadToEnd()
match exn with
| :? WebException as we when not (isNull we.Response) ->
let response = (exn :?> System.Net.WebException).Response
use reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)
let text = reader.ReadToEnd()
tracefnVerbose "Response body was: %s" text
tracefnVerbose "Response: %A" response
| _ -> ()
traceWarnfn "Could not push %s: %s" packageFileName exn.Message
tracefnVerbose "Response body was: %s" text
tracefnVerbose "Response: %A" response
push (trial + 1)

push 1

0 comments on commit 09ed8d5

Please sign in to comment.