Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7899593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:44:36+00:00 2026-06-03T08:44:36+00:00

I have some troubles with my own, user-defined exception in CORBA. Here’s my very

  • 0

I have some troubles with my own, user-defined exception in CORBA. Here’s 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 Implementation.cpp, it gave me some errors (http://pastie.org/private/a22ikk09zkm9tqywn37w):

Implementation.cpp: In member function ‘virtual void Implementation::ffunction(double)’:
Implementation.cpp:5: error: ‘myOwnException’ was not declared in this scope
In file included from Implementation.cpp:1:
Implementation.h:6: error: expected type-specifier before ‘myOwnException’
Implementation.h:6: error: expected ‘)’ before ‘myOwnException’
Implementation.h:6: error: expected ‘;’ before ‘myOwnException’
Implementation.cpp:3: error: expected type-specifier before ‘myOwnException’
Implementation.cpp:3: error: expected ‘)’ before ‘myOwnException’
Implementation.cpp:3: error: expected initializer before ‘myOwnException’

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

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

Note: InterffacePOA.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:44:38+00:00Added an answer on June 3, 2026 at 8:44 am

    You’re supposed to create new instance of exception type, like this:

    throw myOwnException();
    

    You also may need to qualify namespace:

    throw Interfface::myOwnException();
    

    By the way, throw declarations really don’t have any useful effect in most (read “all”) compiler implementations and are deprecated in C++11. I know they probably were autogenerated here, but it’s still good to know. I find that in practice these declarations tend to cease to be accurate with subsequent source changes. Don’t drag them to your implementation files.
    On a second side note, you use uninformative variable and type names, and have no consistent naming convention.

    EDIT:
    As Johnny Willemsen said, you can add members to exceptions like this:

    exception myOwnException {
        string reason;
    };
    

    Each exception member will be represented as a public class member. Necessary constructors will be generated, so you can throw such exception like this:

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

    When exception is thrown, if it is not catched locally, then it gets serialized and propagates to client (remote procedure caller). There it will be deserialized, so you can catch it and access its members kinda like that:

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

    In C++ you usually catch exceptions by constant reference (that also depends on how it was thrown).
    I’m writing this from memory (CORBA stuff), so I hope I’m not missing nothing major.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some troubles with receiving data on server side. Here goes the code:
I have some troubles with positioning my label/password field. With this code they both
I have some troubles with my school project. I have a class: #include Group.h
I have some troubles with plotting the figure. I have a file with some
I have some troubles mapping a JSON Array to RestKit. This is what the
I have some troubles with getting the data from the website. The website source
I have some troubles with a method having a typed List parameter, inherited from
I have some troubles while writing logs from log4net to the file. I seem
Right now I have some troubles. I'm finding a way to solve one problem.
I'm trying to start my java game but I have some troubles with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.