source: subversion/applications/rendering/tilesAtHome/lib/TahExceptions.pm @ 11415

Last change on this file since 11415 was 10312, checked in by matthiasj, 12 years ago

beginnings of better exception handling to avoid needing errors to "bubble up"; starting with Request->fetchFromServer()

File size: 875 bytes
Line 
1use strict;
2
3package TahError;
4
5use overload '""' => \&stringify;
6
7sub new
8{
9    my $class = shift;
10    my $self  = {};
11
12    $self = {
13        error => undef,
14        text => undef,
15    };
16    bless ($self, $class);
17
18    my ($error, $text) = @_;
19    $self->error($error);
20    $self->text($text);
21
22    return $self;
23}
24
25sub error
26{
27    my $self = shift();
28    my $error = shift();
29    if (defined($error))
30    {
31        $self->{error} = $error;
32    }
33    return $self->{error};
34}
35
36sub text
37{
38    my $self = shift();
39    my $text = shift();
40    if (defined($text))
41    {
42        $self->{text} = $text;
43    }
44    return $self->{text};
45}
46
47sub PROPAGATE
48{
49    my $self = shift();
50    return $self;
51}
52
53sub stringify
54{
55    my $self = shift();
56    my $error_string = $self->{error};
57    $error_string .= ": " . $self->{text} if ($self->{text});
58    return $error_string . "\n";
59}
60
611;
Note: See TracBrowser for help on using the repository browser.