File::...::Error(3pm)

πŸ“¦
version 0.906 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay so this is File::KDBX::Error from the User Contributed Perl Documentation, aka the File::...::Error(3pm) page, and it is literally just an object that represents something bad that happened. that's the whole assignment. it's giving emotional support exception. 🫢


✨ VERSION ✨

version 0.906 β€” tiny number, big responsibility πŸ’…


πŸŽ€ ATTRIBUTES πŸŽ€

the lil built-in facts every error object carries around with it, like a wallet full of receipts 🧚

details

\%details = $error->details;

get the error details. that's it, that's the tea πŸ“

errno

get the value of errno at the exact moment the exception was created. like a timestamp but for system errors, no cap.

previous

get the value of $@ (i.e. latest exception) at the time this exception was created. yes bestie it remembers the drama that came before it πŸ’€ iconic behaviour honestly.

trace

get a stack trace indicating where in the code the exception was created. it's giving "here is exactly who did this to you" πŸ‘‘

type

get the exception type, if any. sometimes there's just no type and that's fine, we don't judge 🌸


πŸ”₯ METHODS πŸ”₯

new

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

construct a new error. brand new, fresh out the box, main character energy ✨

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 just gets returned as-is (no notes, periodt). otherwise, whatever you passed gets forwarded to new to create a new error object.

this is so convenient for error handling when you're not sure what the exception is but you wanna 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 πŸ’œ

heads up bestie: this does not contain a stack trace. but you can set the DEBUG environment variable to at least 2 to stringify the whole entire error object. iykyk 😭

throw

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

throw an error. yeet. 😀πŸ’₯

warn

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

log a warning. softer than throw, still loud enough to be heard πŸŽ€

alert

alert $error;

importable alias for warn. same vibe, different name, we love a rebrand 🌈


πŸ› 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. fr fr, a lil repro helps everyone πŸ₯Ί


πŸ‘‘ AUTHOR πŸ‘‘

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.


okay bye bestie πŸ¦‹ this was File::...::Error(3pm) from perl v5.40.1, dated 2025-05-04 β€” thanks for coming to my ted talk, slay, and remember: when something bad happens, at least it's an object now. πŸ’…βœ¨

πŸ“¦ where this page comes from