User-defined CORBA exceptions gave me errors after compilation

I have some problems with my own custom user-defined exception in CORBA. Here is my very simple code:

interface Interfface
{
    exception myOwnException {};

    void ffunction(in double arg) raises (myOwnException);
};

#include "Interfface.hh"

class Implementation : public POA_Interfface
{
    public :
        virtual void ffunction(double arg) throw (myOwnException);
};

#include "Implementation.h"

void Implementation::ffunction(double arg) throw (myOwnException)
{   
    arg ++;    
    throw (myOwnException);
}

And when I compiled Version.cpp, it gave me some errors ( http://pastie.org/private/a22ikk09zkm9tqywn37w ):

Implementation.cpp: In member functionvirtual void Implementation::ffunction(double)’:
Implementation.cpp:5: error: ‘myOwnExceptionwas not declared in this scope
In file included from Implementation.cpp:1:
Implementation.h:6: error: expected type-specifier beforemyOwnExceptionImplementation.h:6: error: expected ‘)’ beforemyOwnExceptionImplementation.h:6: error: expected ‘;’ beforemyOwnExceptionImplementation.cpp:3: error: expected type-specifier beforemyOwnExceptionImplementation.cpp:3: error: expected ‘)’ beforemyOwnExceptionImplementation.cpp:3: error: expected initializer beforemyOwnException

What is wrong with this code? And one more question: how can I do the same in Java?

Here is my code: http://speedy.sh/F5utX/user-defined-exception.tar I did the same in java (the code is also in user-defined-exception.tar), but the java code gave me this:

Note: InterffacePOA.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
+3
source share
1 answer

It is supposed to create a new instance of the exception type, for example:

throw myOwnException();

:

throw Interfface::myOwnException();

, throw (. "" ) ++ 11. , , , , . , , , . . .

EDIT: , :

exception myOwnException {
    string reason;
};

. , :

throw Interfface::myOwnException("Wrong polarity!");

, , ( ). , :

try
{
    server->ffunction(0);
}
catch(const Interfface::myOwnException &ex)
{
    std::cout << ex.reason;
}

++ ( , ). ( CORBA), , .

+2

All Articles