[Koha-bugs] [Bug 24574] Broken MARC records cause "invalid data, cannot decode object" on ISBDdetail and MARCdetail pages.

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Jul 23 09:58:43 CEST 2020


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

--- Comment #20 from Rudolf Byker <rudolfbyker at gmail.com> ---
(In reply to David Cook from comment #15)
> For instance, with this bug report, are you looking to get a generic
> user-friendly web page that says "Sorry, there was an error!" or are you
> looking for the majority of the page to function normally and to handle the
> MARC error specifically to say something like "Sorry, we could not parse
> your MARC record. Please fix the MARC data"?

Definitely the latter! The look and feel of the error page is not what makes in
user-unfriendly. It's that fact work stops and an IT support request is
generated every time some error occurs that could have (should have?) been
handled by Koha.

Just to clarify, it shouldn't be "please fix the MARC data", but rather "here's
how to fix it" or even "click this button to try to fix it automatically".

Then again, if you consider the DB as belonging to Koha (we should) and not to
anyone who would like to run arbitrary INSERTs and UPDATEs, one could just
sanitize the records on import/input and call it a day.

(In reply to David Cook from comment #16)
> If I understand correctly, "checked exceptions" refer to exceptions that are
> caught during compile-time, but the error you're encountering is a run-time
> error. (As far as I know, core Perl doesn't have "checked exceptions", but
> they might be enabled by third-party modules. Koha is starting to use
> Exception::Class more, and I think it might have some support for
> compile-time checks. But really that's irrelevant here.)

No, that's not quite right. Checked exceptions (or the same concept by a
similar name) may exist in compiled and interpreted languages. Checking an
exception means ensuring that, when a function is called that may throw an
exception, that the exception is either caught (and then handled, rethrown, or
a mixture of both) or declared in the function's contract. In a compiled
language, checked means that the compiler does the checking. In interpreted
languages, one would use a linter for that. Moxio has an excellent article on
this. They use PHP, but the principle is language-agnostic.
https://www.moxio.com/blog/34/best-practices-for-php-exception-handling

Another approach is to do what the GO language does, and some C++ projects
compiled with '-fno-exceptions': Don't use exceptions! Whenever something could
throw an exception, it should be caught and converted into an error code. Every
function in the entire project then returns an error code along with its usual
return value. For that, you either need multiple return values (Go, python,
PHP, etc) or pass-by-reference (C, C++, PHP, etc). In many languages, this is
arguably faster than exception handling. Some people also find it clearer.

It is clearly a problem throughout the Koha code base. Which ever solution is
chosen, it should be applied consistently.

> In terms of the run-time, it seems that your Koha is being run by Apache
> executing the Perl scripts as CGI scripts.

Yes, that's right.

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


More information about the Koha-bugs mailing list