[thrift] gut Erlang exception handling

Summary: * move type field to tException from subclasses
          * add backtrace to tException
          * add oop:is_a
          * on exit, wrap exceptions in {thrift_exception, E} ... otherwise can't distinguish e.g. exit:{{tBinProtException, {tException, ...}}, Stack} vs. exit:{tBinProtException, {tException, ...} -- I hate erlang
          * all throws/exits to tException:throw which does the wrapping described above

Reviewed By: eletuchy

Test Plan: been using this code on my live server ^_^

Revert: OK


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665350 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/erl/src/protocol/tBinaryProtocol.erl b/lib/erl/src/protocol/tBinaryProtocol.erl
index 207f305..efcfd77 100644
--- a/lib/erl/src/protocol/tBinaryProtocol.erl
+++ b/lib/erl/src/protocol/tBinaryProtocol.erl
@@ -136,14 +136,13 @@
     ?L1(writeI32, length(Str)),
     ?R1(Trans, effectful_write, Str).
 
-%
+%%
 
 readMessageBegin(This) ->
     Version = ?L0(readI32),
     if
         (Version band ?VERSION_MASK) /= ?VERSION_1 ->
-            throw(tProtocolException:new(?tProtocolException_BAD_VERSION,
-                                         "Missing version identifier"));
+            tException:throw(tProtocolException, [?tProtocolException_BAD_VERSION, "Missing version identifier"]);
         true -> ok
     end,
     Type = Version band 16#000000ff,
@@ -177,7 +176,7 @@
     Size  = ?L0(readI32),
     { Etype, Size }.
 
-%
+%%
 
 readBool(This) ->
     Byte = ?L0(readByte),
diff --git a/lib/erl/src/protocol/tProtocolException.erl b/lib/erl/src/protocol/tProtocolException.erl
index d926aff..84833a8 100644
--- a/lib/erl/src/protocol/tProtocolException.erl
+++ b/lib/erl/src/protocol/tProtocolException.erl
@@ -1,6 +1,6 @@
 %%% Copyright (c) 2007- Facebook
 %%% Distributed under the Thrift Software License
-%%% 
+%%%
 %%% See accompanying file LICENSE or visit the Thrift site at:
 %%% http://developers.facebook.com/thrift/
 
@@ -22,13 +22,12 @@
 %%% 'super' is required unless ?MODULE is a base class
 %%%
 
-?DEFINE_ATTR(super);
-?DEFINE_ATTR(type).
-   
+?DEFINE_ATTR(super).
+
 %%%
 %%% behavior callbacks
 %%%
- 
+
 %%% super() -> SuperModule = atom()
 %%%             |  none
 
@@ -38,15 +37,15 @@
 %%% inspect(This) -> string()
 
 inspect(This) ->
-    ?FORMAT_ATTR(type).
+    "".
 
 %%%
 %%% class methods
 %%%
 
 new(Type, Message) ->
-    Super = (super()):new(Message),
-    #?MODULE{super=Super, type=Type}.
+    Super = (super()):new(Type, Message),
+    #?MODULE{super=Super}.
 
 new() ->
     new(?tProtocolException_UNKNOWN, undefined).