The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Glitch - Exception Handling.

VERSION

Version 0.05

SYNOPSIS

        package Foo;

        use Glitch;

        sub bar {
                do { ... } or glitch('one', message => 'Create a new glitch error message');

                ... later in your code you can then reuse glitch 'one'

                do { ... } or glitch('one');
        }

...

        package Foo;

        use Glitch (
                one => {
                        message => 'Create a new glitch error message'
                },
                two => {
                        message => 'A different glitch error message',
                        fileName => '',
                }
        );

        sub bar {
                eval {
                        do { ... } or glitch('one');
                        ...
                        do { ... } or glitch('two', fileName => 'abc');
                };
                if ($@) {
                        do { ... } if $@->name eq 'one';
                        do { ... } if $@->name eq 'two';
                }
        }

        1;

...

        package Glitches;

        use Glitch (
                glitch_logger => sub {
                        open my $fh, '>', 'glitch.log';
                        print $fh $_[0] . "\n";
                        close $fh;      
                },
                glitch_stringify_format => 'json',
                one => {
                        message => 'Create a new glitch error message'
                },
                two => {
                        message => 'A different glitch error message',
                        fileName => '',
                }
        );

        1;

        package Foo;

        use Glitch;
        use Glitches;

        sub bar {
                eval {
                        do { ... } or glitch('one');
                        ...
                        do { ... } or glitch('two', fileName => 'abc');
                };
                if ($@) {
                        if ($@->name eq 'one') { ... }
                        elsif ($@->name eq 'two') { ... }
                }
        }

        1;

EXPORT

glitch

AUTHOR

LNATION, <email at lnation.org>

BUGS

Please report any bugs or feature requests to bug-glitch at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Glitch. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Glitch

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2022 by LNATION.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)