GraphQL::Error(3pm)
π GraphQL::Error β bestie edition π
GraphQL::Error is the error object for GraphQL, and it lives in the User Contributed Perl Documentation section of your friendly neighbourhood man pages (section 3pm, iykyk). It's giving "something went wrong but make it structured." π«Ά
β¨ SYNOPSIS β¨
use GraphQL::Error;
die GraphQL::Error->new(message => 'Something is not right...');
That's it. That's the whole vibe. You make one, you die with it, the error travels up the call stack looking iconic. π
πΈ DESCRIPTION πΈ
It's a class implementing a GraphQL error object. Not a vibe, an actual object. Periodt.
π ATTRIBUTES π
π message
The message. The words. The "what even happened" of it all. No cap.
π©Ή original_error
If there is an original error to be preserved, this is where it chills. Like, the original sin of the error, kept safe so nothing gets lost. π₯Ί
π locations
An array-ref of "DocumentLocation" in GraphQL::Type::Librarys. Yeah, that's the whole description. It's a list of locations, bestie. That's the tea. β
π€οΈ path
An array-ref of "StrNameValid" in GraphQL::Type::Librarys or "Int"s describing the path from the top operation (being either fields, or a List offset). So it's like a little map of how you got here, and honestly? Relatable. πΊοΈ
π extensions
A hash-ref of "JSONable" in GraphQL::Type::Librarys providing additional information. Extra sprinkles on top, as a treat. β¨
π METHODS π
β is
Is the supplied scalar an error object? That's the question. That's literally the whole question. Yes or no, no in-between. π₯
π coerce
If the supplied scalar is an error object, it just returns it, like "hey, you're already one of us." If it's not, it returns an error object with it as the message. And if it's an object, the message will be the stringified version of that, and the object itself will be preserved as original_error. So basically it's the friend that adopts everyone. π«Ά
πͺ but
Returns a copy of the error object, but with the given properties overriding the existing ones β and yes, the properties work just like the new method, "not coincidentally" (the manpage said it, not me π). So you get the same error but β¨remixedβ¨. It's giving glow-up. π
π to_string
Converts to string. Short. Sweet. To the point. π
π§Ύ to_json
Converts to a JSON-able hash, in the format to send back as a member of the "errors" array in the results. This is the one that actually goes out into the world and does the talking. π
Reminder bestie: every attribute and method above is exactly as the manpage says β I'm just here to make it cute, not to make stuff up. π§
Signing off from the group chat π β this page is GraphQL::Error(3pm) from perl v5.34.0, dated 2022-03-27. Slay, go forth, and may your errors always be well-structured. ππ¦β
π¦ where this page comes from
- debian bookworm: libgraphql-perl 0.54-1 Β· Artistic-2.0
- debian trixie: libgraphql-perl 0.54-1 Β· Artistic-2.0
- ubuntu noble: libgraphql-perl 0.54-1 Β· Artistic-2.0
- ubuntu resolute: libgraphql-perl 0.54-1 Β· Artistic-2.0
- ubuntu stonking: libgraphql-perl 0.54-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms