GraphQL::Error(3pm)

πŸ“¦
version 0.54 Β· 2 versions
  • 0.54 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.53 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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