package Audio::Tagger::Error;
use strict;
use warnings;
#use overload ('""' => 'stringify');

use Error qw( :try );
use base qw/Error/;

sub new
{
	my $self = shift;
	my $text = shift;
	$text = "" if not defined $text;

	local $Error::Depth = $Error::Depth + 1;
	local $Error::Debug = 1;  # Enables storing of stacktrace

	$self->SUPER::new(-text => $text);
}

sub stringify {
	my $self = shift;
	my $text = $self->SUPER::stringify;
	$text =  $self->stacktrace if $text !~ /\n$/s;

	return $text;
}

package Audio::Tagger::Lookup::Error;
use base qw/Audio::Tagger::Error/;
1;

package Audio::Tagger::File::Error;
use base qw/Audio::Tagger::Error/;
1;

package Audio::Tagger::Meta::Error;
use base qw/Audio::Tagger::Error/;
1;

__END__

=head1 NAME

Audio::Tagger::Error - Error-handling for Audio::Tagger

=head1 SYNOPSIS

	try {
		my $tagger = Audio::Tagger->lookup('song.mp3');
	}
	catch Audio::Tagger::Error with {
		my $E = shift;
		print "An error occured, details: " . $E;
	};

=head1 DESCRIPTION

Audio::Tagger::Error is based on L<Error> and allows allows for the use of
try/catch syntax if L<Error> is included.

When one of the Audio::Tagger modules encounters a fatal error it will throw an
error object with details about what went wrong.  If you dont want to handle
these errors in the try/catch fasion the objects will simply be stringfied and
they can be handled as if C<die> was used.

Audio::Tagger objects can will throw the following error objects depending one
what went wrong (all erro objects have a ISA relationship to Audio::Tagger::Error):

=over

=item Audio::Tagger::Error

=item Audio::Tagger::File::Error

=item Audio::Tagger::Meta::Error

=item Audio::Tagger::Lookup::Error

=back

=head1 SEE ALSO

For more information about how to use try/catch see L<Error>.

