Large refactor to:
- Introduce 'Channel' & 'Call' interfaces
- Unify the surfaces for the prototype generated stubs
- Lighten dependency on MessageLite outside of generated code (see Marshaller)
- Bridge Channel to Session pending Transport interface rewrite
- Update all tests to new interfaces

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68407406
diff --git a/core/src/main/java/com/google/net/stubby/Status.java b/core/src/main/java/com/google/net/stubby/Status.java
index 7698533..0095725 100644
--- a/core/src/main/java/com/google/net/stubby/Status.java
+++ b/core/src/main/java/com/google/net/stubby/Status.java
@@ -1,6 +1,7 @@
 package com.google.net.stubby;
 
 import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
 import com.google.net.stubby.transport.Transport;
 
 import javax.annotation.Nullable;
@@ -14,6 +15,18 @@
 
   public static final Status OK = new Status(Transport.Code.OK);
 
+  public static Status fromThrowable(Throwable t) {
+    for (Throwable cause : Throwables.getCausalChain(t)) {
+      if (cause instanceof OperationException) {
+        return ((Status.OperationException) cause).getStatus();
+      } else if (cause instanceof  OperationRuntimeException) {
+        return ((Status.OperationRuntimeException) cause).getStatus();
+      }
+    }
+    // Couldn't find a cause with a Status
+    return new Status(Transport.Code.INTERNAL, t);
+  }
+
   private final Transport.Code code;
   private final String description;
   private final Throwable cause;