Opened 12 years ago

Closed 10 years ago

#371 closed task (fixed)

throw exception when svn_error_t != NULL

Reported by: Peter Johansson Owned by: Peter Johansson
Priority: minor Milestone: svndigest 0.9
Component: core Version: trunk
Keywords: Cc:

Description

Since class SVN is the gateway to libsvn we only need to do this in the SVN class and we can ignore svn_error_t elsewhere. Needless to say the exception thrown could be caught and other propagate all the way to main.

Change History (10)

comment:1 Changed 10 years ago by Peter Johansson

Milestone: svndigest 0.x+svndigest 0.9
Owner: changed from Jari Häkkinen to Peter Johansson
Status: newassigned

comment:2 Changed 10 years ago by Peter Johansson

Two things in SVN::cleanup:

First, the call to

svn_handle_error2(err,stderr,false,"svndigest: ");

assumes that binary is called svndigest, but that is false for svncopyright of course, so I will try to get rid of that call and communicate the error message to main via an Exception.

Second, in this if statement

if (message.length()>0)
  throw SVNException(message);
}

it seems the message is only empty when cleanup is called from cleanup_failed_init and then we are throwing anyway after cleanup returned. In other words, the if statement just makes the code complicated to read.

comment:3 Changed 10 years ago by Peter Johansson

(In [1214]) simplify flow of cleanup code. refs #371

comment:4 Changed 10 years ago by Peter Johansson

(In [1215]) extending SVNException to also hold/take svn_error_t. refs #371

comment:5 Changed 10 years ago by Peter Johansson

(In [1216]) refs #371. avoid using svn_handle_error2 and communicate through exception class instead.

comment:6 Changed 10 years ago by Peter Johansson

(In [1217]) update docs and remove third argument in cleanup_failed_init since the bool was not used in function. refs #371

comment:7 Changed 10 years ago by Peter Johansson

(In [1218]) refs #371. Remove variable binary_ in SVNblame, which was not used. SVNblame will now fail if ued on binary file (but we don't call blame on binary files). The SVN class now takes care of svn errors and translate them into exceptions via the cleanup function.

comment:8 Changed 10 years ago by Peter Johansson

Only one problem left before closing this ticket. As now we don't clear svn_error_t. Not a big deal as most (if not all) errors cause an EXIT_FAILURE.

Most logical is probably if SVNException class takes ownership of the error and delete it in the destructor, but... the problem is the interaction with copying of exception class. I tried to declare copy constructor private but then compiler wouldn't throw the exception.

I need to investigate more, but for now we're leaking...

Thoughts?

comment:9 Changed 10 years ago by Peter Johansson

implement copy constructor with ref counter seems to be the best solution

comment:10 Changed 10 years ago by Peter Johansson

Resolution: fixed
Status: assignedclosed

(In [1219]) closes #371. SVNException copy with ref counter.

Note: See TracTickets for help on using tickets.