Skip to content
Browse files

document X::AdHoc

  • Loading branch information...
1 parent 036f15f commit 1c81143ea2fe515cd935fb0603e85e89e020ae16 @moritz moritz committed Jul 5, 2012
Showing with 33 additions and 0 deletions.
  1. +33 −0 lib/X/AdHoc.pod
View
33 lib/X/AdHoc.pod
@@ -0,0 +1,33 @@
+=begin pod
+
+=TITLE class X::AdHoc
+
+ class X::AdHoc is Exception { ... }
+
+C<X::AdHoc> is the type into which objects are wrapped if they are
+thrown as exceptions, but don't inherit from L<Exception>.
+
+Its benefit over returning non-C<Exception> objects is that it gives
+access to all the methods from class L<Exception>, like C<backtrace>
+and C<rethrow>.
+
+You can obtain the original object with the C<payload> method.
+
+ try {
+ die [404, 'File not found']; # throw non-exception object
+ }
+ say "Got HTTP code ",
+ $!.payload[0], # 404
+ " and backtrace ",
+ $!.backtrace;
+
+=head1 METHODS
+
+=head2 payload
+
+ method payload(X::AdHoc:D)
+
+Returns the original object which was passed to C<die>.
+
+=end pod
+

0 comments on commit 1c81143

Please sign in to comment.
Something went wrong with that request. Please try again.