Open aramwram opened 6 years ago
I am not using this module anymore (I am not even the original author).
I gave you commit/push permissions to this repo, feel free to update the module, I can release it to CPAN once you are happy with it.
It's really kind of you. Thanks. Will do.
I've realized that since Class::Throwable doesn't impose any restrictions on the types of input arguments to the method 'throw' it's possible to implement the above scenario right away without any changes. The only drawback is in the inconsistency between method names and their actual meaning.
Hello, @kmx,
First, I'd like to acknowledge your module. I found it very useful in my project. Good job:)
Lately, I faced some issues which cannot be directly solved using Class::Throwable.
The use-case It might be handy if we allow Class::Throwable to remember some context in which it was called. For example at application level error messages might be used as templates with placeholders, e.g. "Mandatory argument is missing '{arg}'" where {arg} is a placeholder which can be filled with a concrete value when provided a specific context such as { arg => 'some_mandatory_arg' }.
The solution It depends on author's backward compatibility terms.
eval {
....# Do something bad
....2 / 0;
} or do {
....my $error = Class::Throwable->new('Some error');
....$error->setContext({
........detail => $@,
........name1 => value1
........name2 => value2
....});
....throw $error;
};
eval {
....# Do something bad
....2 / 0;
} or do {
....throw 'Some error', { detail => $@, name1 => value1, name2 => value2, ... };
};
@kmx, please, let me know if you're interested in elaborating the above ideas. Please, also clarify your backward compatibility terms.
Aram, gmoyakomora@gmail.com