The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

File::KDBX::Error - Represents something bad that happened

VERSION

version 0.906

ATTRIBUTES

details

    \%details = $error->details;

Get the error details.

errno

Get the value of errno when the exception was created.

previous

Get the value of $@ (i.e. latest exception) at the time the exception was created.

trace

Get a stack trace indicating where in the code the exception was created.

type

Get the exception type, if any.

METHODS

new

    $error = File::KDBX::Error->new($message, %details);

Construct a new error.

error

    $error = error($error);
    $error = error($message, %details);
    $error = File::KDBX::Error->error($error);
    $error = File::KDBX::Error->error($message, %details);

Wrap a thing to make it an error object. If the thing is already an error, it gets returned. Otherwise what is passed will be forwarded to "new" to create a new error object.

This can be convenient for error handling when you're not sure what the exception is but you want to treat it as a File::KDBX::Error. Example:

    eval { ... };
    if (my $error = error(@_)) {
        if ($error->type eq 'key.missing') {
            handle_missing_key($error);
        }
        else {
            handle_other_error($error);
        }
    }

to_string

    $message = $error->to_string;
    $message = "$error";

Stringify an error.

This does not contain a stack trace, but you can set the DEBUG environment variable to at least 2 to stringify the whole error object.

throw

    File::KDBX::Error::throw($message, %details);
    $error->throw;

Throw an error.

warn

    File::KDBX::Error::warn($message, %details);
    $error->warn;

Log a warning.

alert

    alert $error;

Importable alias for "warn".

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/chazmcgarvey/File-KDBX/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

Charles McGarvey <ccm@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Charles McGarvey.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.