Skip to content

Set $@ within catch {} #25

@FGasper

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?

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