[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/include/oop.hrl b/lib/erl/include/oop.hrl
index 84d81e1..66d1a0c 100644
--- a/lib/erl/include/oop.hrl
+++ b/lib/erl/include/oop.hrl
@@ -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/
@@ -16,10 +16,10 @@
%%% convenience for implementing inspect/1
%%% e.g. -> "foo=5"
-define(FORMAT_ATTR(Attr),
- io_lib:write_atom(Attr) ++ "=" ++ io_lib:print(?ATTR(Attr))
+ io_lib:write_atom(Attr) ++ "=" ++ io_lib:print(?ATTR(Attr))
).
--define(ATTR_DUMMY,
- attr(dummy, dummy, dummy, dummy) ->
- throw(dummy_attr_used)
+-define(ATTR_DUMMY,
+ attr(dummy, dummy, dummy, dummy) ->
+ exit(dummy_attr_used)
).
diff --git a/lib/erl/include/protocol/tProtocolException.hrl b/lib/erl/include/protocol/tProtocolException.hrl
index 2de72d7..9d2f31a 100644
--- a/lib/erl/include/protocol/tProtocolException.hrl
+++ b/lib/erl/include/protocol/tProtocolException.hrl
@@ -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/
@@ -10,6 +10,6 @@
-define(tProtocolException_SIZE_LIMIT, 3).
-define(tProtocolException_BAD_VERSION, 4).
--record(tProtocolException, {super, type}).
+-record(tProtocolException, {super}).
diff --git a/lib/erl/include/tApplicationException.hrl b/lib/erl/include/tApplicationException.hrl
index db7ec2f..5e2b515 100644
--- a/lib/erl/include/tApplicationException.hrl
+++ b/lib/erl/include/tApplicationException.hrl
@@ -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/
@@ -13,4 +13,4 @@
-define(tApplicationException_MISSING_RESULT, 5).
-define(tApplicationException_HANDLER_ERROR, 6).
--record(tApplicationException, {super, type}).
+-record(tApplicationException, {super}).
diff --git a/lib/erl/include/tException.hrl b/lib/erl/include/tException.hrl
index 808a474..896e8cb 100644
--- a/lib/erl/include/tException.hrl
+++ b/lib/erl/include/tException.hrl
@@ -1,7 +1,7 @@
%%% 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/
--record(tException, {message}).
+-record(tException, {message, type, backtrace}).
diff --git a/lib/erl/include/thrift_constants.hrl b/lib/erl/include/thrift_constants.hrl
index 8aad0a9..1948061 100644
--- a/lib/erl/include/thrift_constants.hrl
+++ b/lib/erl/include/thrift_constants.hrl
@@ -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/
diff --git a/lib/erl/include/thrift_macros.hrl b/lib/erl/include/thrift_macros.hrl
index 9b8a200..a1a6bad 100644
--- a/lib/erl/include/thrift_macros.hrl
+++ b/lib/erl/include/thrift_macros.hrl
@@ -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/
diff --git a/lib/erl/include/transport/tTransportException.hrl b/lib/erl/include/transport/tTransportException.hrl
index 1a60aad..0fcc99f 100644
--- a/lib/erl/include/transport/tTransportException.hrl
+++ b/lib/erl/include/transport/tTransportException.hrl
@@ -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/
@@ -10,4 +10,4 @@
-define(tTransportException_TIMED_OUT, 3).
-define(tTransportException_END_OF_FILE, 4).
--record(tTransportException, {super, type}).
+-record(tTransportException, {super}).