diff Implab/Diagnostics/Extensions.cs @ 109:1b7ebcc52e5a v2

minor fixes
author cin
date Fri, 14 Nov 2014 14:04:24 +0300
parents a43745f81f10
children 2573b562e328
line wrap: on
line diff
--- a/Implab/Diagnostics/Extensions.cs	Tue Nov 11 18:37:35 2014 +0300
+++ b/Implab/Diagnostics/Extensions.cs	Fri Nov 14 14:04:24 2014 +0300
@@ -4,11 +4,28 @@
             Safe.ArgumentNotNull(promise, "promise");
             var op = TraceContext.Instance.DetachLogicalOperation();
 
-            return promise.Anyway(() => {
-                TraceContext.Instance.EnterLogicalOperation(op,true);
-                TraceLog.EndLogicalOperation();
-                TraceContext.Instance.Leave();
-            });
+            return promise.Then<T>(
+                 x => {
+                    TraceContext.Instance.EnterLogicalOperation(op,true);
+                    TraceLog.TraceInformation("promise = {0}", x);
+                    TraceLog.EndLogicalOperation();
+                    TraceContext.Instance.Leave();
+                    return x;
+                },
+                err =>{
+                    TraceContext.Instance.EnterLogicalOperation(op,true);
+                    TraceLog.TraceError("promise died {0}", err);
+                    TraceLog.EndLogicalOperation();
+                    TraceContext.Instance.Leave();
+                    throw new TransientPromiseException(err);
+                },
+                () => {
+                    TraceContext.Instance.EnterLogicalOperation(op,true);
+                    TraceLog.TraceInformation("promise cancelled");
+                    TraceLog.EndLogicalOperation();
+                    TraceContext.Instance.Leave();
+                }
+            );
         }
 
         public static IPromise EndLogicalOperation(this IPromise promise) {