VM::EC2::Error(3pm)

πŸ“¦
version 1.28 Β· 7 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– VM::EC2::Error πŸ’–

okay so bestie, welcome to VM::EC2::Error β€” the Perl doc for the object that describes an error emitted by the Amazon API. it lives in the User Contributed Perl Documentation section, and honestly? it's giving "small file, big feelings" energy. πŸŽ€


✨ NAME ✨

VM::EC2::Error β€” the object that's literally just here to describe an error emitted by the Amazon API. no cap. that's the whole job. πŸ’…


🌸 SYNOPSIS 🌸

like, here's the vibe in code form:

use VM::EC2;

$ec2      = VM::EC2->new(...);
$instance = $ec2->describe_instance(-instance_id=>'invalid-name');
die $ec2->error if $ec2->is_error;

see how it goes? you make your $ec2, you ask for an instance with an ID that is absolutely not valid, and then you check $ec2->is_error and die with the error. iconic behavior, honestly. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so this object represents an error emitted by the Amazon API. periodt.

here's the part you actually need to internalize: VM::EC2 method calls can return undef under either of two conditions, and these two things are NOT the same thing, bestie:

  1. the request might just simply have no results that satisfy it β€” for example, asking to describe an instance whose ID does not exist. nothing broke, there's just... nothing there. πŸ“
  2. an error occurred due to invalid parameters or communication problems. this one is the actual "something went wrong" situation. 😭

and as described in VM::EC2, here's the dynamic duo you'll be using:

  • VM::EC2->is_error returns true if the last method call resulted in an error.
  • VM::EC2->error returns the content of the error message.

so check is_error first, then grab the goods with error. iykyk. ✨


πŸ‘‘ METHODS πŸ‘‘

these object methods are supported, and there are exactly two of them, so no excuses:

  • message β€” the error message. the actual words of what went wrong. πŸ’¬
  • code β€” the error code. the little categorical tag for it. 🏷️

🌈 STRING OVERLOADING 🌈

okay this part is lowkey delightful: when you use this object in a string context, it will interpolate the code and the message into a single string, in this exact format:

"Message [Code]"

so it just shows up looking cute and readable wherever you shove it into a string. no extra work from you. main character energy. πŸ’…


🧚 SEE ALSO 🧚

go read these too, they're the friend group:

  • VM::EC2
  • VM::EC2::Generic

πŸ’œ AUTHOR πŸ’œ

Lincoln Stein <lincoln.stein@gmail.com>.

Copyright (c) 2011 Ontario Institute for Cancer Research

and here's the legal bit, fr fr β€” this package and its accompanying libraries is free software; you can redistribute it and/or modify it under the terms of the GPL (either version 1, or at your option, any later version) or the Artistic License 2.0. refer to LICENSE for the full license text. in addition, please see DISCLAIMER.txt for disclaimers of warranty. 🫢


okay bestie that's the whole page, go forth and check is_error before you die πŸ’–

mwah β€” this lil rewrite is running on perl v5.38.2, dated 2024-08-10, and yeah that's VM::EC2::Error(3pm) signing off. slay. βœ¨πŸ’…πŸŽ€

πŸ“¦ where this page comes from