[Koha-bugs] [Bug 25039] Move new due calculation to Koha::Checkout

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Apr 2 14:19:04 CEST 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25039

--- Comment #3 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
(In reply to Jonathan Druart from comment #2)
> From bug 25020 comment 6:
> 
> """
> A quick note, I think this kind of tests is overkill and not needed:
> 
> +        Koha::Exceptions::WrongParameter->throw(
> +            "'hard_due_date' must be a DateTime object"
> +        ) unless $hard_due_date->isa('DateTime');

I disagree. If we require a specific data type on the 'hard_due_date' param, we
need to check it, otherwise we could have bad code working correctly in 'some'
circumstances but failing of edge cases.

> +        Koha::Exceptions::WrongParameter->throw(
> +            "'days' must be an integer"
> +        ) unless looks_like_number($days);
> +        $due_date->add( days => $days );
>
> Developers will get an error anyway if $days is not an integer (DateTime
> will raise its own meaningful exception), or $hard_due_date is not a
> DateTime

I agree here, but we try to translate those exceptions into Koha::Exceptions,
right?

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list