Error Handling

All Corrigo web services methods return a result object that represents the results of the method call. Result objects are broadly classified into either the CorrigoEntity class or the CommandResponse class however, command specific result objects can also be used.
Error handling for CorrigoEntity result set objects is managed using try-catch blocks.
The CommandResponse class returns error codes to manage error handling. All errors are returned as a error code - error message combination. Error codes can be retrieved using ErrorInfo.Number and error messages can be retrieved using ErrorInfo.Description.

CorrigoEntity

Retrieve method returns a CorrigoEntity object.

CorrigoEntity result = null;
try
{
  result = (CorrigoEntity) corrigoService.Retrieve(new EntitySpecifier(), new AllProperties());
}
catch (Exception e)
{
  Console.WriteLine(e.Message);
}

CorrigoEntity Collection

RetrieveMultiple method returns a CorrigoEntity collection object.

CorrigoEntity[] results = null;
try
{
  results = corrigoService.RetrieveMultiple(new QueryByProperty());
}
catch (Exception e)
{
  Console.WriteLine(e.Message);
}

CommandResponse

Execute method returns a CommandResponse object.

CommandResponse result = corrigoService.Execute(new CommandRequest);

if (result.ErrorInfo != null)
{
   Console.WriteLine(result.ErrorInfo.Number + " : " + result.ErrorInfo.Description);
}

CommandResponse Collection

ExecuteMultiple method returns a CommandResponse collection object.

CommandResponse[] results = corrigoService.ExecuteMultiple(new CommandRequest[] { });

if(results.Length > 0)
{
   foreach (CommandResponse commandResponse in results) 
   { 
      if (commandResponse.ErrorInfo != null)
      {
         Console.WriteLine(commandResponse.ErrorInfo.Number + " : " +
         commandResponse.ErrorInfo.Description);
      }
   }
}

Entity Specific Response

When Entity specific commands are specified, Entity specific command response classes can be used.
Example: WoActionResponse is the result object for the WoReopenCommand.

WoActionResponse results = (WoActionResponse)corrigoService.Execute(
  new WoReopenCommand { WorkOrderId = workOrderId });

if (results.ErrorInfo != null)
{
   Console.WriteLine(results.ErrorInfo.Number + " : " + results.ErrorInfo.Description);
}