Skip to content

Instantly share code, notes, and snippets.

@bjartwolf
Created December 15, 2014 18:21
Show Gist options
  • Save bjartwolf/f3538780c28f09a6c9c4 to your computer and use it in GitHub Desktop.
Save bjartwolf/f3538780c28f09a6c9c4 to your computer and use it in GitHub Desktop.
logging and rhrowing exceptions
let logResultOfSending (logger: IEventIDLog) (receiverNumber : string) (body : string) (status : SmsStatus) =
match status with
| Response result ->
let logg = logresponse receiverNumber body result
match result with
| Success -> logg SmsSent.EventId logger.Info
| Fail -> logg SmsError.EventId logger.Error
| Error ex ->
logger.Error(SmsError.EventId, "error sending sms", ex)
status
// NServiceBus handles recovery from failure based on the app throwing exceptions
let throwExceptionsWhenMessagesAreNotSent(status : SmsStatus) =
match status with
| Response result ->
match result with
| Success -> ()
| Fail ->
raise (SmsException("delivery failed", result))
| Error e ->
raise e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment