[omniORB] Throwing standard exceptions from application code

Duncan Grisby duncan@grisby.org
Thu Dec 12 14:46:01 2002


On Wednesday 11 December, =?iso-8859-1?q?H=E9ctor=20Escolar?= wrote:

> Is possible to throw a standard exception from application code?
> I want to throw a CORBA::NO_RESOURCES when my app detects some 
> non-recoverable errors due to fail allocating a file descriptor, but i don't 
> know if this is legal according to the CORBA standard.

Yes, it's possible and legal. You should abide by the meanings of the
exceptions to avoid confusion. It's sensible to throw NO_RESOURCES in
the situation you explain, but would be wrong to throw
OBJECT_NOT_EXIST, for example.

> What's the appropiate way to do this? I see things like 
> OMNIORB_THROW(NO_RESOURCES,0,CORBA::COMPLETED_NO); 
> in omniORB source code (3.0.4).

OMNIORB_THROW is a macro that prints out the line number doing the
throwing when using trace level 10. For application code, it's
suitable to just to throw CORBA::NO_RESOURCES(0, CORBA::COMPLETED_NO).
That is portable between ORBs.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan@grisby.org     --
   -- http://www.grisby.org --