This question is answered.


Permlink Replies: 5 - Pages: 1 - Last Post: 10 May 21, 14:33 Last Post By: JeffTucker Threads: [ Previous | Next ]
ctwist

Posts: 474
Registered: 27-Sep-2003
Better error handling
Posted: 9 May 21, 04:51
 
  Click to reply to this thread Reply
I am working on an improved technique for handling album errors.

This is where I stand:
  • I distinguish errors from warnings.
  • An error must be fixed in order to create a viable album.
  • A warning identifies a problem that may or may not be of concern. The album will be generated and it will be error-free, but some components may be missing.
  • Most errors are detected and reported before album generation starts. This error checking takes a few seconds.
  • If an error is found, I want to prevent album generation (before it has started).
So:
If I am in predir.bsh for the root directory, how can I instruct jAlbum to abandon album generation?
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: Better error handling
Posted: 9 May 21, 07:18   in response to: ctwist in response to: ctwist
Correct
  Click to reply to this thread Reply
Take a look at the veAbort() method in the init.bsh of the Venus skin. To see it in action, add a few images to a new project and hit Make Album (Venus wants everything in folders, not at the root).

If possible, it's better to detect errors that require an abort in init.bsh, rather than waiting until predir.bsh, to minimize the "partial album" clutter.
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: Better error handling
Posted: 10 May 21, 14:06   in response to: ctwist in response to: ctwist
Helpful
  Click to reply to this thread Reply
The correct way to abort an album making operation is to throw OperationAbortedException:
throw new OperationAbortedException("Possible reason here");
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: Better error handling
Posted: 10 May 21, 14:27   in response to: davidekholm in response to: davidekholm
Helpful
  Click to reply to this thread Reply
Ah, I see I don't need to do my own JOptionPane - I was just paralleling what I do for other warnings that I toss up, where's there's no existing method for it.

But without the proper code, it doesn't make the ribbit sound. Where's the fun in that?
ctwist

Posts: 474
Registered: 27-Sep-2003
Re: Better error handling
Posted: 10 May 21, 14:29   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Well, that was simple. It's easy when I know what to look for!

I do the validation in predir.bsh because some validation must be done after jAlbum has completed its initialization. I am not concerned about "partial album clutter"; I assume that the user will correct the error and make the album again before opening the album.

However, maybe I can move some validation to init.bsh. I will look into it.
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: Better error handling
Posted: 10 May 21, 14:33   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
The now-fixed routine, per David's enlightenment:
private void veAbort(String var) {
	dor = new Frog();
	dor.ribbit();
	throw new OperationAbortedException(var);
}
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums