Skip to content

Set $@ within catch {} #25

Description

@FGasper

The fact of using $_ rather than $@ within catch {} blocks has a couple of unfortunate effects:

  1. You lose access to $_ from outside the try/catch. This has never really bothered me, but I could see it bugging someone who uses $_ in iterations more than I do.

  2. Setting $@ is the only way to get PROPAGATE from Perl exceptions. The fact that T::T uses a different variable makes anyone who wants PROPAGATE to do local $@ = $_; within every catch {} where we might potentially rethrow the exception. This is annoying.

I propose a flag, and/or some other means, of telling Try::Tiny to set a local()ized $@ as the exception variable within catch {} blocks.

Thoughts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions