Murray Brown
asked on
VB.net catch Xero exceptions
Hi. I am using the following code to catch errors in the Xero API.The following has the ValidationException, but there are other exceptions like .APIException and .BadRequestException
How do I get the information on Exceptions if there are more than one of these types of Exception?
Catch ex As Xero.Api.Infrastructure.Ex ceptions.V alidationE xception
For Each v In ex.ValidationErrors
System.Diagnostics.Debug.W riteLine(v .Message)
oValidationErrors = oValidationErrors & " " & v.Message
Next
Response.Write("Error Line Details " & oValidationErrors)
End Try
How do I get the information on Exceptions if there are more than one of these types of Exception?
Catch ex As Xero.Api.Infrastructure.Ex
For Each v In ex.ValidationErrors
System.Diagnostics.Debug.W
oValidationErrors = oValidationErrors & " " & v.Message
Next
Response.Write("Error Line Details " & oValidationErrors)
End Try
Check whether all these exceptions have a base exception you can catch. Otherwise you need to what we all have to do in such a scenario: Catch them all explicitly, thus a catch clause for each of them.
ASKER
Thanks can you have multiple catch clauses for one Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great! Thanks very much