private void RunProcessor(API.Request request, Processor processor, string processorName)
{
API.Response response = null;
try
{
// Threadpooling
response = processor.process(request);
}
catch (Exception e)
{
Logger.Error("Failed to process message with processor " + processor.GetType() + " : " + e.Message, e);
try
{
Type responseType = Type.GetType("Gwupe.Cloud.Messaging.Response." + processorName + "Rs");
response = (API.Response) responseType.GetConstructor(Type.EmptyTypes).Invoke(new object[] {});
response.error = "UNKNOWN_ERROR";
response.errorMessage = e.Message;
}
catch (Exception exception)
{
Logger.Error("Failed to determine return type for " + processorName);
response = new ErrorRs
{
errorMessage = "Failed to determine return type for " + processorName,
error = "INTERNAL_SERVER_ERROR"
};
}
}
finally
{
SendResponse(response, request);
}
}
}