# Base class for exception handling.
# 09.08.2004

package XcBase;
use warnings;
use strict;

use overload '""' => \&to_string;

sub to_string {
    "$_[0]->{'ctx'}: $_[0]->{'tx'}\n";
}

sub new {
    my ($class, $tx ) = @_;
    
    my ($pkg, $file, $line, $subr) = caller( 0 );
    
    my $this = { 'tx' => $tx, 
                 'fl' => "$file:$line",
                 'sub' => "${pkg}::$subr",
                 'ctx' => "$file:$line: (${pkg}::$subr)" };
    
    bless( $this, ref( $class ) || $class );
}

1;
