Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Corba > Re: checking fo...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 7 Topic 476 of 543
Post > Topic >>

Re: checking for org.omg.CORBA.OBJECT_NOT_EXIST

by Jonathan Biggar <jon@[EMAIL PROTECTED] > Jan 25, 2007 at 06:48 PM

ke_jin@[EMAIL PROTECTED]
 wrote:
>>>> Just write your own wrapper function that calls non_existent(),
catches
>>>> the exceptions you want, and returns different error codes for
different
>>>> exceptions.  Once you've done that, you can reuse that code
everywhere
>>>> without having to write lots of catch() blocks.
>>> Then, you would end up with exactly same "lots of" switch/case blocks
>>> :).
>> Not if you design the error codes right, or make predicate functions
>> that you can reuse that translate the error code to a boolean value.
>>
> 
> As long as your wrapper "returns different error codes for different
> exceptions".

You're missing my point.

> Here is an example:
> 
> original code with many try/catch:
> 
>     try {
>        ....
>    }
>    catch(exception a) {
>       handle_exception_a(...);
>    }
>    catch(exception b) {
>       handle_exception_b(...);
>    }
>    ...
> 
> wrapper that "returns different error codes for different exceptions":
> ...
> 
> int wrapper() {
>    ...
>    try {
>        ....
>    }
>    catch(exception a) {
>       return error_code_a;
>    }
>    catch(exception b) {
>       return error_code_b;
>    }
>    ...
> }
> 
> Use of this wrapper:
> 
>    ...
>    switch(wrapper()) {
>       case error_code_a: handle error a; break;
>       case error_code_b: handle error b; break;
>      ...
>    }

Or:

bool error_codes_i_care_about(error code e) {
	switch (e) {
	case error_code_a:
	case error_code_c:
		return true;
	default:
		return false;
	}
}

error_code wrapper(CORBA::Object_ptr obj) {
	try {
		....
	}
	catch(exception a) {
		return error_code_a;
	}
	catch(exception b) {
		return error_code_b;
	}
	...
}

bool wrapper(CORBA::Object_ptr obj, bool (*predicate)(errror_code)) {
	return predicate(wrapper(obj));
}

	...
	if (wrapper(obj, error_codes_i_care_about)) {
		// handle errors I care about
	else
		// do something else
	...

-- 
Jon Biggar
Floorboard Software
jon@[EMAIL PROTECTED]

 




 7 Posts in Topic:
checking for org.omg.CORBA.OBJECT_NOT_EXIST
donalmurtagh@[EMAIL PROTE  2007-01-22 07:38:24 
Re: checking for org.omg.CORBA.OBJECT_NOT_EXIST
ke_jin@[EMAIL PROTECTED]   2007-01-23 09:05:34 
Re: checking for org.omg.CORBA.OBJECT_NOT_EXIST
Jonathan Biggar <jon@[  2007-01-23 18:35:04 
Re: checking for org.omg.CORBA.OBJECT_NOT_EXIST
ke_jin@[EMAIL PROTECTED]   2007-01-24 10:23:20 
Re: checking for org.omg.CORBA.OBJECT_NOT_EXIST
Jonathan Biggar <jon@[  2007-01-24 18:28:56 
Re: checking for org.omg.CORBA.OBJECT_NOT_EXIST
ke_jin@[EMAIL PROTECTED]   2007-01-24 11:15:24 
Re: checking for org.omg.CORBA.OBJECT_NOT_EXIST
Jonathan Biggar <jon@[  2007-01-25 18:48:57 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 17:29:13 CDT 2008.