Do i have to parse the entire content of the response, or could we introduce a prefix?
Example:
For cache_code-invaild, i get currently the response "Parameter 'cache_code' has invalid value: This cache does not exist."
If you send me "CacheCodeInvalidException: Parameter 'cache_code' has invalid value: This cache does not exist.", i could check for string before : and throw exactly that exception. This would also enable us to throw localized exceptions.
Or should be use a JSON-structured-response?
My current code (entire string is compared):
Code: Alles auswählen
Friend Class KnownExceptions
Public Const CacheCodeInvalid As String = "Parameter 'cache_code' has invalid value: This cache does not exist."
Public Const ConsumerKeyInvalid As String = "Parameter 'consumer_key' has invalid value: Consumer does not exist."
Public Shared Function GetKnwonException(ByVal ex As BadRequestException) As Exception
Select Case ex.Message
Case CacheCodeInvalid
Return New CacheCodeInvalidException(ex.Message, ex)
Case ConsumerKeyInvalid
Return New ConsumerKeyInvalidException(ex.Message, ex)
Case Else
Return ex
End Select
End Function
End Class