HTTP::OAI::Error(3pm)

πŸ“¦
version 4.13 Β· 5 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– HTTP::OAI::Error πŸ’–

okay so bestie, welcome to HTTP::OAI::Error β€” she's the little Perl module (you'll find her hanging out in the User Contributed Perl Documentation section of your manual, section 3pm obviously πŸ’…) whose whole entire job is encapsulating OAI error codes. that's it. that's the gig. she holds the error code and the error message so you don't have to 🫢


✨ METHODS ✨

  • $err = new HTTP::OAI::Error(code=>'badArgument',[message=>'An incorrect argument was supplied']) β€” this constructor method returns a new HTTP::OAI::Error object. iconic behaviour honestly πŸ‘‘

and here's the cute part: if you don't pass in a message, and the code happens to be a valid OAI error code, then the default message is the appropriate message from the OAI protocol document. so she'll fill in the blanks for you, no cap. πŸŽ€

  • $code = $err->code([$code]) β€” returns the error name, and optionally sets it if you hand her a $code. get it, set it, slay πŸ’…
  • $msg = $err->message([$msg]) β€” returns the error message, and optionally sets it if you hand her a $msg. same energy, different field πŸ¦‹

🚨 NOTE β€” noRecordsMatch 🚨

okay this one is the plot twist, so listen up fr fr:

noRecordsMatch, without additional errors, is not treated as an error code. like, she refuses to be dramatic about it πŸ™ˆ

so if a repository returns noRecordsMatch, the HTTP::OAI::Response object will have a verb of 'error' and will contain the noRecordsMatch error β€” BUT β€” is_success will still return true. yes bestie, both things at once. it's giving "technically an error, emotionally a success" 😭

e.g.

my $r = $ha->ListIdentifiers(metadataPrefix='oai_dc',from=>'3000-02-02');

if( $r->is_success ) {
        print "Successful\n";
} else {
        print "Failed\n";
}

print $r->verb, "\n";

this will print "Successful" followed by "error". and yes that's the whole point, that's the vibe check, that's the demo. ⭐


and that's the whole page, bestie πŸ’œ this was perl v5.36.0, dated 2023-09-28, and she's filed under HTTP::OAI::Error(3pm) β€” go forth and handle your errors with main character energy πŸ‘‘βœ¨πŸŒΈ

πŸ“¦ where this page comes from