Skip to content

Commit

Permalink
Preserve the error information from SharpXMPP
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Jul 20, 2019
1 parent fa71018 commit 877144c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Emulsion/Xmpp/XmppClient.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Emulsion.Xmpp.XmppClient

open System
open System.Threading.Tasks

open SharpXMPP
Expand Down Expand Up @@ -42,17 +43,15 @@ let create (settings: XmppSettings) (onMessage: IncomingMessage -> unit): XmppCl
client.add_Message(messageHandler settings onMessage)
client

exception ConnectionFailedError of string
with
override this.ToString() =
sprintf "%A" this
type ConnectionFailedError(message: string, innerException: Exception) =
inherit Exception(message, innerException)

let run (client: XmppClient): Async<unit> =
printfn "Bot name: %s" client.Jid.FullJid
let connectionFinished = TaskCompletionSource()
let connectionFailedHandler =
XmppConnection.ConnectionFailedHandler(
fun _ error -> connectionFinished.SetException(ConnectionFailedError error.Message)
fun _ error -> connectionFinished.SetException(ConnectionFailedError(error.Message, error.Exception))
)

async {
Expand Down

0 comments on commit 877144c

Please sign in to comment.