~ubuntu-branches/ubuntu/trusty/rakudo/trusty

« back to all changes in this revision

Viewing changes to src/core/Exceptions.pm

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2012-06-08 15:50:16 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120608155016-bh432n9g3j8p7s68
Tags: 0.1~2012.04.1-1
* New upstream release
* Bump required nqp and parrot version
* Explicitly set nqp path during configure
* Re-word long description
* Use dh_parrot debhelper plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# XXX should really be my X::Base eventually
2
 
my class X::Base is Exception {
3
 
    has $.message;
4
 
 
5
 
    multi method Str(X::Base:D:) {
6
 
        $.message.Str // 'Something went wrong'
7
 
    }
8
 
    method ID() { ... }
9
 
    multi method gist(X::Base:D:) {
10
 
        $.message ~ "\n" ~ $.backtrace;
11
 
    }
12
 
}
13
 
my role X::OS {
14
 
    has $.os-error;
15
 
}
16
 
 
17
 
my role X::Comp {
18
 
    has $.filename;
19
 
    has $.line;
20
 
    has $.column;
21
 
    multi method gist(::?CLASS:D:) {
22
 
        "===SORRY!===\n$.message\nat $.filename():$.line";
23
 
    }
24
 
}
25
 
 
26
 
my class X::NYI is X::Base {
27
 
    has $.feature;
28
 
    method message() { "$.feature not yet implemented. Sorry. " }
29
 
}
30
 
 
31
 
my class X::OutOfRange is X::Base {
32
 
    has $.what = 'Argument';
33
 
    has $.got = '<unknown>';
34
 
    has $.range = '<unknown>';
35
 
    method message() {
36
 
        "$.what out of range. Is: $.got, should be in $.range"
37
 
    }
38
 
}
39
 
 
40
 
my class X::Buf::AsStr is X::Base {
41
 
    has $.method;
42
 
    method message() {
43
 
        "Cannot use a Buf as a string, but you called the $.method method on it";
44
 
    }
45
 
}
46
 
 
47
 
my class X::Signature::Placeholder is X::Base does X::Comp {
48
 
    method message() {
49
 
        'Placeholder variable cannot override existing signature';
50
 
    }
51
 
}
52
 
 
53
 
my class X::Attribute::Undeclared is X::Base does X::Comp {
54
 
    has $.name;
55
 
    has $.package-type;
56
 
    has $.package-name;
57
 
    method message() {
58
 
        "Attribute $.name not declared in $.package-type $.package-name";
59
 
    }
60
 
}
61
 
 
62
 
my class X::Obsolete is X::Base does X::Comp {
63
 
    has $.old;
64
 
    has $.new;
65
 
    has $.when = 'in Perl 6';
66
 
    method message() { "Unsupported use of $.old; $.when please use $.new" }
67
 
}