=begin pod

=TITLE class X::AdHoc

=SUBTITLE Error with a custom error message

    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;

Note that young code will often be prototyped using C<X::AdHoc> and
then later be revised to use more specific subtypes of C<Exception>.
As such it is usually best not to explicitly rely on receiving an
C<X::AdHoc> -- in many cases using the string returned by the
C<.message> method, which all C<Exception>s must have, is preferable.

=head1 Methods

=head2 method payload

    method payload(X::AdHoc:D)

Returns the original object which was passed to C<die>.

=end pod

