Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. # Add them if you've got them.
  2.  
  3. our class X::NativeCall::DeadObject is Exception {
  4. has $.status = "no longer valid for use";
  5. has $.type = "UNSPECIFIED";
  6. has $.lib = "any library";
  7. method message {
  8. "This object of type $.type is $.status with $.lib."
  9. }
  10. }
  11.  
  12. our class X::NativeCall::CannotClone is Exception {
  13. has $.type = "UNSPECIFIED";
  14. method message {
  15. "Native object of type $.type cannot be cloned."
  16. }
  17. }
  18.  
  19. our class X::NativeCall::OverflowProhibited is Exception {
  20. has $.dtype;
  21. has $.value;
  22.  
  23. method message {
  24. my $dtype = " of " ~ $!dtype if $!dtype.chars;
  25. my $value = " by value" ~ $!value if $!value.chars;
  26. "Prohibited overflow$dtype$value because that is dangerous here.";
  27. }
  28. }
  29.  
  30. our class X::NativeCall::NativeError is Exception {
  31. has $.errno = "";
  32. has $.error = "";
  33. has $.func = "";
  34. has $.lib = "";
  35.  
  36. method message {
  37. my $m = "Unexpected error from native API call";
  38. $m ~= " ($.errno)" if $.errno.chars;
  39. $m ~= ": $.error" if $.error.chars;
  40. if $.func.chars or $.lib.chars {
  41. $m ~= " (in ";
  42. $m ~= " function $.func" if $.func.chars;
  43. $m ~= " library $.lib" if $.lib.chars;
  44. $m ~= ")";
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement