NAME

FP::Repl::WithRepl

SYNOPSIS

    use FP::Repl::WithRepl;
    withrepl { die "foo"; };  # shows the exception, then runs a repl
                              # within the exception context

    push_withrepl (0); # turn on using a repl globally, but storing the
                       # previous handler on a stack; the argument says
                       # how many levels from the current one to go back
                       # for the search of 'eval' (the WORKAROUND, see
                       # below)

    WithRepl_eval ...; # like `eval` but transparent for WithRepl
                       # handlers (takes an optional package argument, by
                       # default the caller's package is used)

    my ($v,$e,$is_error)= WithRepl_eval_e("code",$maybe_package);
                       # unlike WithRepl_eval and eval, this safely
                       # returns the result of the given code, or $e==$@
                       # and $is_error==1 in case of an exception/error.

    pop_withrepl; # restore the handler that was pushed last.

DESCRIPTION

Sets `$SIG{__DIE__}` to a wrapper that shows the exception then calls a repl from FP::Repl. This means, when getting an exception, instead of terminating the program (with a message), you get a chance to inspect the program state interactively.

Note that it currently employs a WORKAROUND to check from within the sig handler whether there's a new `(eval)` frame on the stack between the point of the handler call and the point of the handler installation (or n frames back from there, as per the argument to `push_withrepl`).

NOTE

This is alpha software! Read the status section in the package README or on the website.