JSON::...::Error(3pm)

πŸ“¦
version 0.11 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

JSON::RPC::Common::Procedure::Return::Error β€” bestie, it's the base class for all the JSON-RPC errors πŸ’– (and yeah the man page header just calls it JSON::...::Error(3pm) because man page headers are cowards who truncate, but you and me? we know her full name πŸ‘‘)


🌸 VERSION 🌸

version 0.11 β€” that's the one, no cap πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

okay so here's the whole vibe, literally copy-paste this:

use JSON::RPC::Common::Procedure::Return::Error;

my $error = JSON::RPC::Common::Procedure::Return::Error->new(
        message => "foo",
        code => "bah",
);

# or construct a return with an error from a call:
my $return = $call->return_error("foo");

$return->error->message;

see how she did that? new with a message and a code, or just slide in via $call->return_error("foo") and grab $return->error->message like it's nothing 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

This is a base class for all version specific error implementations. That's it. That's the whole job. She's the mother of all error classes and she is serving main character energy without even trying ✨


πŸ’œ ATTRIBUTES πŸ’œ

  • code
  • message
  • data

These three are the common JSON-RPC error fields, fr fr πŸ“

In JSON-RPC 1.1, "data" is known as "error", and in 1.0 none of this is specced at all πŸ’€ (yes bestie, 1.0 said "no thoughts, head empty" and we respect that, but also 😭)

Go peep the version specific subclasses for the various behaviors, because they each do their own little thing ✨

Oh and heads up: code is an integer, and message is a string. Don't be out here passing vibes where an integer goes πŸ™ˆ


🌈 METHODS 🌈

  • new_dwim β€” convenience constructor used by "return_error" in JSON::RPC::Common::Procedure::Call πŸŽ€ Will return an object if that's the argument, and otherwise construct an error. Like, she reads the room. If you hand her an object she gives it right back, if you hand her anything else she makes you a fresh error. Versatile queen πŸ’…
  • inflate β€” create an error object from JSON data (not text) πŸ¦‹ In order to maximize compatibility this inflation routine is very liberal in what it accepts β€” she is not picky, she says yes to almost everything, she's the friendliest bouncer you've ever met 😌

πŸ’– AUTHOR πŸ’–

Yuval Kogman <nothingmuch@woobling.org> β€” legend behavior, honestly 🌟


This software is copyright (c) 2014 by Yuval Kogman and others πŸ’–

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Slay, open source, we love to see it 🌸


okay bestie that's the whole page, you're so ready πŸ’… go forth and error correctly ✨

perl v5.30.3 Β· 2020-06-23 Β· and that's the <pink>JSON::...::Error(3pm)</pink> sign-off, mwah πŸŽ€πŸ«ΆπŸ’–

πŸ“¦ where this page comes from