Re: Directory masks -- howto?

Denis Corbin <[email protected]>
Newsgroups gmane.comp.sysutils.backup.dar.general
Message-ID <[email protected]>
Johnathan Burchill wrote:
> On October 15, 2003 11:28 am, Johnathan Burchill wrote:
> 
> [...]
> 
> By the way, exception handling does not work in either the qt/kde 
> environment, or with this simple command-line example.
> 
> 
>>So here is an example file ("dar-test-create") which reproduces my
>>problem.
>>
>>#include <iostream>
>>#include <string>
>>#include <libdar.hpp>
>>#include <erreurs.hpp>
>>
>>using namespace std;
>>using namespace libdar;
>>
>>void interaction_warning (const std::string &);
>>bool interaction_pause (const std::string &);
>>
>>int main ( )
>>{
>>        set_warning_callback(&interaction_warning);
>>        set_answer_callback(&interaction_pause);
>>
>>	user_interaction_warning("Basic program working");
>>	try
>>	{
>>		user_interaction_pause("About to create the archive. Do you wish to
>>continue?");
>>	}
>>	catch (Euser_abort &e)
>>	{
> 
> 
> Suppose I insert an obvious message here:
> 		cout << "You did the right thing." << endl;
> 
> 
>>		user_interaction_warning(e.get_message());
>>		return -1;
>>	}
> 
> 
> Now this never gets printed when I do not continue writing the archive.
> The only output is "Aborted".

strange, it worked for me, I got the following output:

Basic program working
About to create the archive. Do you wish to continue?n
You did the right thing.
About to create the archive. Do you wish to continue?

"abort" let me think the program did not caught the exception, and thus 
escaped from the main() function, which aborted the program. Which 
compilation command do you use to build the executable ?

> 
> Am I doing something obviously incorrect here?



> 
> BTW, I see in doc/DOC_API that you plan to keep exceptions at the libdar 
> level only for version 2 of the API. That will allow "no-exception"-built 
> libraries (default for qt and kde) to link to libdar and not segfault when 
> the user answers no, right?

yes, each call to libdar (op_create and so on) will receive a global 
statment

	try
	{
		// curent code here
	}
	catch()
	{
	....
	}

that will convert any thrown exception to error code which will be 
returned by the call (I will probably re-use dar exit code status).
And add a new call will be added to get the message string of the 
corresponding exception. This string will be stored in the 
<datastructure> to be defined which will be given as first argument
of each call, and which will be the base of the open/close paradigm.

But, segfault should not occure in the example you gave. The idea behind
containing the exception in libdar was to have a more C friendly 
interface to let people that are not familiar with C++ but with C, have 
a chance to use the API. But, in my opinion, exceptions is very powerful
to manage error cases, and much better than error code, but, ... this is 
just my opinion. ;-)

> 
> Thanks,
> JB
> 
> [...]
> 

Denis.



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.