Cisco Cisco TelePresence Management Suite (TMS) Version 15 Developer's Guide
Error handling examples
The following code examples demonstrate how to handle errors generated from API calls.
Conference in the past
Running this code will output the message: "You cannot book a conference in the past".
public
void
HandleError_BookInThePast()
{
InitBookingService();
Conference conference = bookingService.GetDefaultConference();
var
start = DateTime.Now.AddHours(-10);
var
end = start.AddMinutes(10);
conference.StartTimeUTC = start.ToString(
"u"
);
conference.EndTimeUTC = end.ToString(
"u"
);
try
{
conference = bookingService.SaveConference(conference);
}
catch
(SoapException e)
{
Console.WriteLine(
"Got error with error code {0}, and message {1}, from Booking API"
, e.Detail.
InnerXml, e.Message);
}
PrintConferenceInformation(conference);
}
System unavailable
Running the code below will output a "system unavailable" message.
public
void
HandleError_SystemNotAvailable()
{
InitBookingService();
Conference conference = bookingService.GetDefaultConference();
var
start = DateTime.Now.AddHours(1);
var
end = start.AddMinutes(10);
conference.StartTimeUTC = start.ToString(
"u"
);
conference.EndTimeUTC = end.ToString(
"u"
);
Participant participant =
new
Participant {ParticipantCallType = ParticipantType.TMS, ParticipantId
= 4};
conference.Participants =
new
[]
{
participant
};
bookingService.SaveConference(conference);
try
{
// By setting the Id to -1, we try to book a new conference, with the same time and participant
conference.ConferenceId = -1;
Cisco TMSBA Programming Reference Guide
Page 65 of 68
Code examples