File: error.pm

package info (click to toggle)
diskless 0.3.18.0.5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 772 kB
  • ctags: 119
  • sloc: perl: 2,628; xml: 782; sh: 439; makefile: 103
file content (64 lines) | stat: -rw-r--r-- 998 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package error;
use strict;
return 1;

# Create a new error
sub new
{
        my $proto = shift;
        my $class = ref($proto) || $proto;
        my $self = {
		id => shift,
		msg => shift,
        };
        bless($self,$class);
        return $self;
}

sub process
{
        my $proto = shift;
	my $name = shift;
	my $status = shift;

	my $exit_value  = $status >> 8;
	my $signal_num  = $status & 127;
	my $dumped_core = $status & 128;

	return $proto->new("error"->general,
 			"$name: exit=$exit_value, ".
      			"signal=$signal_num, core=$dumped_core");
}

# Return error message to display to user
sub msg
{
	my $self=shift;
	return $self->{"msg"};
}

# Return error id so that program can take appropriate action
sub id
{
	my $self=shift;
	return $self->{"id"};
}

# limited selection of error codes, so that program
# can determine if error is fatal or not.
# this list should really be updated.

sub general
{
	return 1;
}

sub notfound
{
	return 2;
}

sub alreadyexists
{
	return 3;
}