2 #include "tao/Messaging/ExceptionHolder_i.h"
4 #include "tao/Messaging/Messaging.h"
5 #include "tao/Exception_Data.h"
10 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
14 ExceptionHolder::ExceptionHolder () :
22 ExceptionHolder::ExceptionHolder (
23 ::CORBA::Boolean is_system_exception
,
24 ::CORBA::Boolean byte_order
,
25 const ::CORBA::OctetSeq
&marshaled_exception
,
26 ::TAO::Exception_Data
* data
,
27 ::CORBA::ULong exceptions_count
,
28 ACE_Char_Codeset_Translator
*char_translator
,
29 ACE_WChar_Codeset_Translator
*wchar_translator
) :
30 ::OBV_Messaging::ExceptionHolder (is_system_exception
, byte_order
, marshaled_exception
),
32 count_ (exceptions_count
),
33 char_translator_ (char_translator
),
34 wchar_translator_ (wchar_translator
)
38 ExceptionHolder::~ExceptionHolder ()
43 ExceptionHolder::set_exception_data (::TAO::Exception_Data
* data
,
44 ::CORBA::ULong exceptions_count
)
47 this->count_
= exceptions_count
;
50 void ExceptionHolder::raise_exception ()
52 TAO_InputCDR
_tao_in ((const char*) this->marshaled_exception ().get_buffer (),
53 this->marshaled_exception ().length (),
56 _tao_in
.char_translator (this->char_translator_
);
57 _tao_in
.wchar_translator (this->wchar_translator_
);
59 CORBA::String_var type_id
;
61 if (!(_tao_in
>> type_id
.inout ()))
63 // Could not demarshal the exception id, raise a local
65 throw ::CORBA::MARSHAL (TAO::VMCID
, CORBA::COMPLETED_YES
);
68 if (this->is_system_exception ())
70 CORBA::ULong minor
= 0;
71 CORBA::ULong completion
= 0;
72 if (!(_tao_in
>> minor
) ||
73 !(_tao_in
>> completion
))
75 throw ::CORBA::MARSHAL (TAO::VMCID
, CORBA::COMPLETED_MAYBE
);
78 CORBA::SystemException
* exception
=
79 TAO::create_system_exception (type_id
.in ());
83 // @@ We should raise a CORBA::NO_MEMORY, but we ran out
84 // of memory already. We need a pre-allocated, TSS,
85 // CORBA::NO_MEMORY instance
86 ACE_NEW (exception
, CORBA::UNKNOWN
);
88 exception
->minor (minor
);
89 exception
->completed (CORBA::CompletionStatus (completion
));
91 // Raise the exception.
92 std::unique_ptr
<CORBA::SystemException
> e_ptr(exception
);
98 // Match the exception interface repository id with the
99 // exception in the exception list.
100 // This is important to decode the exception.
101 for (CORBA::ULong i
= 0; i
!= this->count_
; ++i
)
103 if (ACE_OS::strcmp (type_id
.in (), this->data_
[i
].id
) != 0)
106 CORBA::Exception
* const exception
= this->data_
[i
].alloc ();
110 throw ::CORBA::NO_MEMORY (TAO::VMCID
, CORBA::COMPLETED_YES
);
114 exception
->_tao_decode (_tao_in
);
117 // Raise the exception.
118 std::unique_ptr
<CORBA::Exception
> e_ptr (exception
);
119 exception
->_raise ();
124 // If we couldn't find the right exception, report it as
127 // @@ It would seem like if the remote exception is a
128 // UserException we can assume that the request was
130 throw ::CORBA::UNKNOWN (TAO::VMCID
, CORBA::COMPLETED_YES
);
133 void ExceptionHolder::raise_exception_with_list (
134 const ::Dynamic::ExceptionList
&)
136 // todo convert exceptionlist to something we can really use.
137 this->raise_exception ();
141 ExceptionHolder::_copy_value ()
143 TAO::ExceptionHolder
* ret_val
= 0;
144 ACE_NEW_THROW_EX (ret_val
,
146 CORBA::NO_MEMORY ());
148 // @todo According to the latest corba spec we should be able to
149 // pass this to the ExceptionHolder constructor but the TAO_IDL
150 // compiler doesn't seem to generate this.
151 ret_val
->is_system_exception (this->is_system_exception ());
152 ret_val
->byte_order (this->byte_order ());
153 ret_val
->marshaled_exception (this->marshaled_exception ());
159 ExceptionHolderFactory::create_for_unmarshal ()
161 TAO::ExceptionHolder
* ret_val
= 0;
162 ACE_NEW_THROW_EX (ret_val
,
164 CORBA::NO_MEMORY ());
169 TAO_END_VERSIONED_NAMESPACE_DECL