Catching up after the holidays.
[kakapo:kakapo.git] / src / Exceptions.nqp
1 # Copyright (C) 2009, Austin Hastings. See accompanying LICENSE file, or 
2 # http://www.opensource.org/licenses/artistic-license-2.0.php for license.
3
4 module Kakapo::ExceptionWrapper;
5 # Wrapper for Exception PMC because I can't get it working right now.
6
7 INIT {
8         use(    'P6metaclass' );
9         has(    '$!exception' );
10 }
11
12 method create_exception() {
13         return Exception.new;
14 }
15
16 method exit_code(*@value)               { self.exception._attr('exit_code', @value); }
17 method handled(*@value)         { self.exception._attr('handled', @value); }
18
19 method _init_(@pos, %named) {
20         self.exception(self.create_exception);
21         self.exception.type(self.severity);
22         self.exception.type(self.type);
23         self._init_args_(@pos, %named);
24 }
25
26 method message(*@value)         { self.exception._attr('message', @value); }
27 method payload(*@value)         { self.exception._attr('payload', @value); }
28 method severity()                       { Exception::Severity.SEVERE; }
29 method throw()                          { self.exception.throw; }
30 method type()                           { self.__ABSTRACT__; }
31
32 class Exception::IllegalOperation                       is Kakapo::ExceptionWrapper;
33 method type()                           { return 1000; }
34 class Exception::AbstractMethodInvocation       is Exception::IllegalOperation;
35 method type()                           { return 1001; }
36
37 class Exception::MethodNotFound                 is Kakapo::ExceptionWrapper;
38 method type()                           { return 45; }
39
40 class Exception::UnitTestFailure                        is Kakapo::ExceptionWrapper;
41  method severity()                      { Exception::Severity.ERROR; }
42 method type()                           { return 1002; }