Skip to content

Instantly share code, notes, and snippets.

@mikehadlow
Created July 14, 2017 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikehadlow/06dafe9457a76aa5bc5a75639a376bf5 to your computer and use it in GitHub Desktop.
Save mikehadlow/06dafe9457a76aa5bc5a75639a376bf5 to your computer and use it in GitHub Desktop.
private XmlElement FaultFromException(Exception exception)
=> (exception is TargetInvocationException targetInvocationException)
? FaultFromException(targetInvocationException.InnerException)
: (exception is SonosException sonosException)
? XmlElementFromFault(new SoapFault
{
FaultCode = sonosException.FaultCode,
FaultString = sonosException.FaultString,
Detail = sonosException.Detail
})
: XmlElementFromFault(new SoapFault
{
FaultCode = SonosException.ServiceUnknownError,
FaultString = $"{exception.GetType().Name}: '{exception.Message}'",
Detail = exception.ToString()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment