DOKK / manpages / debian 12 / libfile-kdbx-perl / File::KDBX::Error.3pm.en
File::KDBX::Error(3pm) User Contributed Perl Documentation File::KDBX::Error(3pm)

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

version 0.906

    \%details = $error->details;

Get the error details.

Get the value of "errno" when the exception was created.

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

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

Get the exception type, if any.

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

Construct a new 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);
        }
    }

    $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.

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

Throw an error.

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

Log a warning.

    alert $error;

Importable alias for "warn".

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.

Charles McGarvey <ccm@cpan.org>

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.

2022-11-20 perl v5.36.0