Permalink
Browse files

[common] Stub in a simple NQPException exception object and a die sub.

  • Loading branch information...
1 parent 973c96d commit 6a07cb256cf55cc44926a4ccb6038441655f5237 @jnthn committed Oct 22, 2010
Showing with 32 additions and 0 deletions.
  1. +32 −0 common/NQP/NQPSetting.pm
View
32 common/NQP/NQPSetting.pm
@@ -217,6 +217,38 @@ sub &infix:<~>($x, $y) {
nqp::concat($x.Str, $y.Str);
}
+# A basic, fairly bare-bones exception object.
+knowhow NQPException {
+ has $!message;
+ has $!resumable;
+
+ method new($message) {
+ nqp::instance_of(self.WHAT).BUILD(:message($message))
+ }
+
+ method BUILD(:$message) {
+ $!message := $message;
+ $!resumable := 0;
+ self;
+ }
+
+ method resumable() {
+ $!resumable
+ }
+
+ method resume() {
+ $!resumable := 1;
+ }
+
+ method Str() {
+ $!message
+ }
+}
+
+sub die($message) {
+ nqp::throw_dynamic(NQPException.new($message), 0)
+}
+
# For tests.
my $count := NQPInt.new();
sub plan($n) {

0 comments on commit 6a07cb2

Please sign in to comment.