summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-11-03 13:35:54 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-11-03 13:35:54 +0100
commitd2e8a2c02abe05214bb77496121d9a0277f3e95f (patch)
treef29aedd71a19b16f17bdd4312871f5b04d41065b
parentf8e537573beadf071dd2698590be05b53120f51a (diff)
Add error decoder
-rw-r--r--include/opcodes.hrl1
-rw-r--r--src/error.erl5
-rw-r--r--src/rose.erl8
3 files changed, 12 insertions, 2 deletions
diff --git a/include/opcodes.hrl b/include/opcodes.hrl
index 6f0b123..6fb8550 100644
--- a/include/opcodes.hrl
+++ b/include/opcodes.hrl
@@ -1,3 +1,4 @@
+-define(ERROR, {local, 1}).
-define(MAKECALL, {local, 10}).
-define(EVENT, {local, 21}).
-define(ESCAPE, {local, 51}).
diff --git a/src/error.erl b/src/error.erl
new file mode 100644
index 0000000..7be31a2
--- /dev/null
+++ b/src/error.erl
@@ -0,0 +1,5 @@
+-module(error).
+-export([decode/1]).
+
+decode(Data) ->
+ 'CSTA-error-definition':decode('ErrorValue', Data).
diff --git a/src/rose.erl b/src/rose.erl
index a98df07..9df46a7 100644
--- a/src/rose.erl
+++ b/src/rose.erl
@@ -46,9 +46,13 @@ dispatch({returnResult, #'ReturnResult'{invokeId = Id, result = Data}}) ->
counter:set(Id),
dispatch(Data);
-dispatch({returnError, #'ReturnError'{invokeId = Id, errcode = Code, parameter = Par}}) ->
+dispatch({returnError, #'ReturnError'{invokeId = Id, errcode = Op, parameter = Data}}) ->
counter:set(Id),
- io:format("Err: ~p ~p~n", [Code, Par]),
+ case Op of
+ ?ERROR ->
+ {ok, Error} = error:decode(Data),
+ io:format("Error: ~p~n", [Error])
+ end,
error;
dispatch({reject, #'Reject'{invokeId = Id, problem = Problem}}) ->