[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Mac::Glue error handlers



I am thinking about changing how error handlers work.  Right now, they get
6+ arguments, which is just a bit unwieldy.  I am thinking of either
changing the order of the arguments, or passing in a hashref instead.
Right now:


	0	The glue object
	1	The event object (same object returned by RETOBJ)
	2	The Glue's name
	3	The event's name
	4	The error message
	5	The error number
	6..n	Any arguments passed to the event in the first place

I am thinking of:


	0	The glue object
	1	The error message
	2	The error number
	3	The Glue's name
	4	The event's name
	5	The event object (same object returned by RETOBJ)
	6..n	Any arguments passed to the event in the first place

But really think this might be better:

	{
		OBJ	=> The glue object
		RETOBJ	=> The event object (same object returned by RETOBJ)
		ERRS	=> The error message
		ERRN	=> The error number
		GLUE	=> The Glue's name
		EVENT	=> The event's name
		ARGS	=> [arguments passed to the event in the first place]
	}

So instead of:

	sub error_handler {
		my($glue, $event, $gluename, $eventname,
			$errs, $errn, @args) = @_;
		my $args = join ', ', @args;
		die "$gluename->$eventname($args) event failed:\n$errs\n";
	}

You can just do:

	sub error_handler {
		my $err = shift;
		my $args = join ', ', @{$err->{args}};
		die "$err->{GLUE}\->$err->{EVENT}($args) event failed:
$err->{ERRS}\n";
	}

I think this would make it better.  Thoughts?  The big problem I have here
is changing the public interface, especially since we are already at a 1.00
release.  But I don't think too many people have taken advantage of this
yet, and it is not a major change.

-- 
Chris Nandor                      pudge@pobox.com    http://pudge.net/
Open Source Development Network    pudge@osdn.com     http://osdn.com/

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org