| 1 | # the contents of this file are Copyright (c) 2004-2009 David Blood | ||
| 2 | # This program is free software; you can redistribute it and/or | ||
| 3 | # modify it under the terms of the GNU General Public License as | ||
| 4 | # published by the Free Software Foundation. | ||
| 5 | |||
| 6 | ################################## | ||
| 7 | package DBR::Admin::Exception; | ||
| 8 | |||
| 9 | use strict; | ||
| 10 | use Error; | ||
| 11 | use Curses::UI; | ||
| 12 | |||
| 13 | use base 'Error'; | ||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | sub new { | ||
| 18 | |||
| 19 | my $package = shift; | ||
| 20 | my %_in = @_; | ||
| 21 | |||
| 22 | local $Error::Depth = $Error::Depth + 1; | ||
| 23 | local $Error::Debug = 1; # Enables storing of stacktrace | ||
| 24 | |||
| 25 | $_{message} ||= 'No message specified'; | ||
| 26 | |||
| 27 | my $self = $package->SUPER::new(-text => $_in{message}); | ||
| 28 | |||
| 29 | $self->{message} = $_in{message}; | ||
| 30 | $self->{root_window} = $_in{root_window}; | ||
| 31 | |||
| 32 | return $self; | ||
| 33 | } | ||
| 34 | |||
| 35 | sub get_message { | ||
| 36 | |||
| 37 | my $self = shift; | ||
| 38 | return $self->{message}; | ||
| 39 | } | ||
| 40 | |||
| 41 | sub stringify { | ||
| 42 | |||
| 43 | my $self = shift; | ||
| 44 | if ($self->{root_window}) { | ||
| 45 | $self->{root_window}->error($self->{message}); | ||
| 46 | print STDERR $self->{-stacktrace}; | ||
| 47 | # $self->{root_window}->error($self->{-stringify}); | ||
| 48 | } | ||
| 49 | else { | ||
| 50 | return $self->{-stacktrace}; | ||
| 51 | } | ||
| 52 | |||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | |||
| 58 | 1; |