r1519@opsdev009 (orig r80499): mcslee | 2008-01-30 17:49:16 -0800
[amiethrift.git] / lib / erl / src / tApplicationException.erl
blobd99b0037bbf2aad02bdb66d065be351c3986fce1
1 %%% Copyright (c) 2007- Facebook
2 %%% Distributed under the Thrift Software License
3 %%%
4 %%% See accompanying file LICENSE or visit the Thrift site at:
5 %%% http://developers.facebook.com/thrift/
7 -module(tApplicationException).
9 -include("thrift.hrl").
10 -include("tApplicationException.hrl").
12 -include("oop.hrl").
14 -behavior(oop).
16 -export([attr/4, super/0, inspect/1]).
18 -export([new/0, new/1, new/2, read/2, write/2]).
20 %%%
21 %%% define attributes
22 %%% 'super' is required unless ?MODULE is a base class
23 %%%
25 ?DEFINE_ATTR(super).
27 %%%
28 %%% behavior callbacks
29 %%%
31 %%% super() -> SuperModule = atom()
32 %%% | none
34 super() ->
35 tException.
37 %%% inspect(This) -> string()
39 inspect(This) ->
40 "".
42 %%%
43 %%% class methods
44 %%%
46 new(Type, Message) ->
47 Super = (super()):new(Type, Message),
48 #?MODULE{super=Super}.
50 new() -> new(?tApplicationException_UNKNOWN, undefined).
51 new(Type) -> new(Type, undefined).
53 %%%
54 %%% instance methods
55 %%%
57 read(This, Iprot) ->
58 ?R0(Iprot, readStructBegin),
59 read_while_loop(This, Iprot),
60 ?R0(Iprot, readStructEnd),
61 ok.
63 read_while_loop(This, Iprot) ->
64 {_Fname, Ftype, Fid} = ?R0(Iprot, readFieldBegin),
67 Ftype == ?tType_STOP ->
68 ok;
70 (Fid == 1) and (Ftype == ?tType_STRING) ->
71 Message1 = ?R0(Iprot, readString),
72 This1 = oop:set(This, message, Message1),
73 ?R0(Iprot, readFieldEnd),
74 read_while_loop(This1, Iprot);
76 Fid == 1 ->
77 ?R0(Iprot, skip),
78 ?R0(Iprot, readFieldEnd),
79 read_while_loop(This, Iprot);
81 (Fid == 2) and (Ftype == ?tType_I32) ->
82 Type1 = ?R0(Iprot, readI32),
83 This1 = oop:set(This, type, Type1),
84 ?R0(Iprot, readFieldEnd),
85 read_while_loop(This1, Iprot);
87 true ->
88 ?R0(Iprot, skip),
89 ?R0(Iprot, readFieldEnd),
90 read_while_loop(This, Iprot)
91 end.
93 write(This, Oprot) ->
94 ?R1(Oprot, writeStructBegin, "tApplicationException"),
95 Message = oop:get(This, message),
96 Type = oop:get(This, type),
98 if Message /= undefined ->
99 ?R3(Oprot, writeFieldBegin, "message", ?tType_STRING, 1),
100 ?R1(Oprot, writeString, Message),
101 ?R0(Oprot, writeFieldEnd);
102 true -> ok
103 end,
105 if Type /= undefined ->
106 ?R3(Oprot, writeFieldBegin, "type", ?tType_I32, 2),
107 ?R1(Oprot, writeI32, Type),
108 ?R0(Oprot, writeFieldEnd);
109 true -> ok
110 end,
112 ?R0(Oprot, writeFieldStop),
113 ?R0(Oprot, writeStructEnd),