File: Error.pm

package info (click to toggle)
carton 1.0.35-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 448 kB
  • sloc: perl: 1,207; makefile: 7
file content (42 lines) | stat: -rw-r--r-- 737 bytes parent folder | download | duplicates (4)
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
package Carton::Error;
use strict;
use overload '""' => sub { $_[0]->error };
use Carp;

sub throw {
    my($class, @args) = @_;
    die $class->new(@args);
}

sub rethrow {
    die $_[0];
}

sub new {
    my($class, %args) = @_;
    bless \%args, $class;
}

sub error {
    $_[0]->{error} || ref $_[0];
}

package Carton::Error::CommandNotFound;
use parent 'Carton::Error';

package Carton::Error::CommandExit;
use parent 'Carton::Error';
sub code { $_[0]->{code} }

package Carton::Error::CPANfileNotFound;
use parent 'Carton::Error';

package Carton::Error::SnapshotParseError;
use parent 'Carton::Error';
sub path { $_[0]->{path} }

package Carton::Error::SnapshotNotFound;
use parent 'Carton::Error';
sub path { $_[0]->{path} }

1;