Net::T...::Error(3pm)

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

πŸ’– NAME πŸ’–

ok so bestie, <pink>Net::Twitter::Lite::Error</pink> β€” it's the little ✨vessel✨ that holds onto all the errors that <purple>Net::Twitter::Lite</purple> yeets at you. Like, when the vibes go wrong, this is the object that catches them. 🫢


πŸŽ€ VERSION πŸŽ€

this is <cyan>version 0.12008</cyan>, no cap πŸ‘‘


🌸 SYNOPSIS 🌸

ok here's the whole vibe in four lines, slay:

use Net::Twitter::Lite;
my $nt = Net::Twitter::Lite->new;
my $r = eval { $nt->friends_timeline };
warn "$@\n" if $@;

like, you wrap the call in eval, and if something goes sideways, $@ is holding the <pink>Net::Twitter::Lite::Error</pink> object. iconic behavior honestly. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

<pink>Net::Twitter::Lite::Error</pink> is literally the container for every error that <purple>Net::Twitter::Lite</purple> decides to throw. 🫠

and when one of these objects shows up, it's packing an HTTP::Response, plus a HASHREF stuffed with Twitter API error info β€” but only if Twitter actually sent one back. so sometimes it's full, sometimes it's just the response. vibe check dependent. ✨


πŸ’œ METHODS πŸ’œ

  • new β€” builds you a fresh <pink>Net::Twitter::Lite::Error</pink> object. you hand it an HTTP::Response, and optionally a Twitter error HASH ref. it takes a HASH of arguments, so no positional nonsense. examples, look:
my $e = Net::Twitter::Lite::Error->new(http_response => $res, twitter_error => $te);
my $e = Net::Twitter::Lite::Error->new(http_response => $res);

see how the second one skips twitter_error? yeah, it's optional, she's flexible πŸ’

  • twitter_error β€” get or set the encapsulated Twitter API error HASH ref. that's it, that's the whole job. πŸ“
  • http_response β€” get or set the encapsulated HTTP::Response instance. same energy. 🧚
  • code β€” returns the HTTP Status Code from the encapsulated HTTP::Response. the number, the digits, the ✨receipts✨
  • message β€” returns the HTTP Status Message from the encapsulated HTTP::Response. the words that go with the number. πŸ’¬
  • error β€” okay this one's the main character. returns an error message as a string. here's the priority order, bestie:
    • if there's an error element in the encapsulated Twitter API HASH ref, that's what you get πŸ‘‘
    • otherwise, it returns a string containing the HTTP Status Code and Message
    • and if the <pink>Net::Twitter::Lite::Error</pink> instance has neither an HTTP::Response nor a Twitter Error HASH ref, or if the HTTP::Response has no status code or message β€” then error returns the string '[unknown]'. yeah. mystery era. πŸ•΅οΈ

oh and also? a Net::Twitter::Lite::Error stringifies to the error message. so if you just drop it into a string, that's what comes out. no conversion arc needed. πŸŽ€


🌈 SEE ALSO 🌈

Net::Twitter::Lite β€” the parent of all this drama. go read that one too fr fr 🫢


✨ AUTHOR ✨

Marc Mims <marc@questright.com> β€” shoutout to the legend, we love to see it πŸ‘‘


πŸ’… LICENSE πŸ’…

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. slay, open source rights πŸ’–


ok that's the whole page, we ate and left no crumbs 🍽️✨ this was <cyan>perl v5.34.0</cyan> documenting things as of <cyan>2022-06-16</cyan> β€” ty for coming to my ted talk, ily, go catch your errors bestie πŸ’œπŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from