In this topic:
The MethodResult type is mostly used for operation that could produce exception.
For input/output exception, instead of throwing exception in the runtime, the language returns this type of value to indicates if the operation succeed.
Returns True when the operation succeed, otherwise it return False and chance is to have an ErrorMessage which indicates the reason of failure.
Return a Boolean.
Dim items As Variant
Dim result = items.LoadJSON("incorrect json format")
result.Success ' => False
Dim isOk As Variant
Dim result = isOk.LoadJSON("true")
result.Success ' => True
Returns the code of failure. It's always DK when the Success is True, or when there is no error code provided by the API that throw the exception.
Return a Number.
Dim items As Variant
Dim result = items.LoadJSON("incorrect json format")
result.Success ' => False
result.ErrorMessage ' => "SyntaxError: Unexpected token i in JSON at position : 0"
result.ErrorCode ' => DK
Returns the reason of failure. It's always empty when the Success is True, and most of time non-empty when it's False
Return a String.
Dim items As Variant
Dim result = items.LoadJSON("incorrect json format")
result.Success ' => False
result.ErrorMessage ' => "SyntaxError: Unexpected token i in JSON at position : 0"
Dim isOk As Variant
Dim result = isOk.LoadJSON("true")
result.Success ' => True
result.ErrorMessage ' => ""
Returns a string which represent the result (express in JSON format).
Return a String.
Dim items As Variant
Dim result = items.LoadJSON("invalid json format")
' Output in a single line (it's break here for the readability)
result.ToString() ' => "{
'"success":false,
'"errorCode":-999999.99,
'"errorMessage":"SyntaxError: Unexpected token i in JSON at position : 0"
'}"
Always returns "methodresult".
Return a String.
Dim items As Variant
Dim result = items.LoadJSON("invalid json format")
result.TypeOf() ' => "methodresult"