Esempio n. 1
0
        public void SetExceptionResult(Exception exception, string operation, MessagePayloadDataConverter errorDataConverter)
        {
            this.ExceptionType = exception.GetType().AssemblyQualifiedName;

            try
            {
                this.Result = errorDataConverter.Serialize(exception);
            }
            catch (Exception)
            {
                // sometimes, exceptions cannot be serialized. In that case we create a serializable wrapper
                // exception which lets the caller know something went wrong.

                var wrapper = string.IsNullOrEmpty(operation) ?
                              new OperationErrorException($"{this.ExceptionType} while processing operations: {exception.Message}")
                    : new OperationErrorException($"{this.ExceptionType} in operation '{operation}': {exception.Message}");

                this.ExceptionType = wrapper.GetType().AssemblyQualifiedName;
                this.Result        = errorDataConverter.Serialize(wrapper);
            }
        }
Esempio n. 2
0
 public void SetResult(object result, MessagePayloadDataConverter dataConverter)
 {
     this.ExceptionType = null;
     if (result is JToken jtoken)
     {
         this.Result = jtoken.ToString(Formatting.None);
     }
     else
     {
         this.Result = dataConverter.Serialize(result);
     }
 }
 public void SetInput(object obj, MessagePayloadDataConverter dataConverter)
 {
     try
     {
         if (obj is JToken jtoken)
         {
             this.Input = jtoken.ToString(Formatting.None);
         }
         else
         {
             this.Input = dataConverter.Serialize(obj);
         }
     }
     catch (Exception e)
     {
         throw new EntitySchedulerException($"Failed to serialize input for operation '{this.Operation}': {e.Message}", e);
     }
 }