Re: [cgiapp] exception handling? Re-iterated Patch Request

2002-11-06 Thread A.M.
How about the following solution:

use base 'CGI::Application';

sub X
{
	my $self=shift;
	
	$SIG{__WARN__}=sub{$self-param('WARN',$_[0]);};
	$SIG{__DIE__}=sub($self-param('DIE',$_[0]);};
	my $ret='htmlbodyhi/body/html';
	
	return $self-param('DIE') if $self-param('DIE');
	#or return your exception handling web page with debugging info if 
desired
	return $self-param('WARN') if $self-param('WARN');
	return $ret;
}

To throw exceptions, just warn or die as necessary. I suppose this 
could be setup in cgiapp_init. This is what I'm using. Suggestions?

On Wednesday, November 6, 2002, at 01:17  PM, David Ranney wrote:


I second this idea. I am also overriding the run() method in my 
subclass of CGI::App to deal with exception handling.

-Dave

On Tuesday, November 5, 2002, at 05:17  PM, Thilo Planz wrote:

For you to keep your hashref exception object intact, you could

die ( $@ ) if ($@);


Yes, this is what I do now.
But I am not happy with overloading (and duplicating) the whole run() 
method to just change a single line.

I really think the cleanest way is to have the additional callback 
method cgiapp_exception.

===
PATCH REQUEST

 # Process run mode!
my $body = eval { $autoload_mode ? $self-$rmeth($rm) : 
$self-$rmeth()};
die $self-cgiapp_exception($rm,  $@);


Default would be

sub cgiapp_exception{
	my ($self, $rm, $exception) = @_;
	die Error executing run mode '$rm': $exception;
}


-
Web Archive:  http://www.mail-archive.com/cgiapp;lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





AgentM
[EMAIL PROTECTED]




-
Web Archive:  http://www.mail-archive.com/cgiapp;lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: [cgiapp] exception handling? Re-iterated Patch Request

2002-11-05 Thread Thilo Planz
Hello,



(1) That error (line #156, CGI::Application 2.4) only happens when you 
map
your run modes like so:

'select_document', = 'select_document',

	but will not occur if the run mode is directly mapped (this holds the
method to the current package I believe.)

'select_document', = \select_document,

Thanks for the hint, that would have worked for me.

But note that this part has changed in CGI::Application 2.6.

It is now:

 # Process run mode!
my $body = eval { $autoload_mode ? $self-$rmeth($rm) : 
$self-$rmeth()};
die Error executing run mode '$rm': $@ if $@;

So, it will eval and die (in a way useless to me) in both cases.


(2) You _might_ be able to modify the suggested code (in the above 
mailing
list reference) to place that data INTO the hash, and then directly
propagate that error.  In my other post, I suggest :


die ($@ . Error executing run mode '$rm'.  Eval of code '$meth_call'
resulted in error.) if ($@);

For you to keep your hashref exception object intact, you could

die ( $@ ) if ($@);


Yes, this is what I do now.
But I am not happy with overloading (and duplicating) the whole run() 
method to just change a single line.

I really think the cleanest way is to have the additional callback 
method cgiapp_exception.

===
PATCH REQUEST

 # Process run mode!
my $body = eval { $autoload_mode ? $self-$rmeth($rm) : 
$self-$rmeth()};
die $self-cgiapp_exception($rm,  $@);


Default would be

sub cgiapp_exception{
	my ($self, $rm, $exception) = @_;
	die Error executing run mode '$rm': $exception;
}

==

Cory would have used

sub cgiapp_exception{
	my ($self, $rm, $exception) = @_;
	die $exception Error executing run mode '$rm'. ;
}

I would use

sub cgiapp_exception{
	my ($self, $rm, $exception) = @_;

	# exception handling
}

Jesse, can I please have this method ?

I can pay with a postcard from Tokyo ;-)


Cheers,

Thilo


PS: patch file for 2.6 attached



cgiapp_exception.patch
Description: application/text



-
Web Archive:  http://www.mail-archive.com/cgiapp;lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]