Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

It is always possible for your request to return an error. If an error occurs, e.g. if your API username/password is incorrect, our wrapper will throw a C# exception. If you're not familiar with handling exceptions in C#, it basically means you need to put the wrapper function calls in a try-catch block as shown in the example:

Code Block
themeRDark
languagec#
titleExample
linenumberstrue
try {
	Hashtable result;
	result = tmClient.sendSMS("My message", "447000000000", "Sender", 72, "", "", null);
} catch(RestClientException e) {
	Hashtable errors = tmClient.getLastErrors();
}

You must decide how to handle errors according to the logic of your particular application.
For example, if you're building a web interface to send text messages, and a send fails, you may wish to show a visual alert to the user.
Note that more than one error can be reported at once. Therefore although a single C# exception (the first of the errors) is thrown, the complete set of errors encountered is available in a Hashtable of key-value pairs. The key of each pair is the error code and the value is a detailed description of the error.

Code Block
themeRDark
languagec#
titleExample
linenumberstrue
foreach (DictionaryEntry de in tmClient.getLastErrors())
	Console.WriteLine("Error {0}: {1}", de.Key, de.Value);
Warning
titleYou must know!

Our example code is an illustration of how you might integrate with our systems and is not certified for production environments. You are responsible for testing and QA.