| 1 | package VM::EC2::Error; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | VM::EC2::Error - Object describing an error emitted by the Amazon API | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use VM::EC2; | ||
| 10 | |||
| 11 | $ec2 = VM::EC2->new(...); | ||
| 12 | $instance = $ec2->describe_instance(-instance_id=>'invalid-name'); | ||
| 13 | die $ec2->error if $ec2->is_error; | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | This object represents an error emitted by the Amazon API. VM::EC2 | ||
| 18 | method calls may return undef under either of two conditions: the | ||
| 19 | request may simply have no results that satisfy it (for example, | ||
| 20 | asking to describe an instance whose ID does not exist), or an error | ||
| 21 | occurred due to invalid parameters or communication problems. | ||
| 22 | |||
| 23 | As described in L<VM::EC2>, the VM::EC2->is_error method returns true if | ||
| 24 | the last method call resulted in an error, and VM::EC2->error returns | ||
| 25 | the content of the error message. | ||
| 26 | |||
| 27 | =head1 METHODS | ||
| 28 | |||
| 29 | These object methods are supported: | ||
| 30 | |||
| 31 | message -- the error message | ||
| 32 | code -- the error code | ||
| 33 | |||
| 34 | =head1 STRING OVERLOADING | ||
| 35 | |||
| 36 | When used in a string context, this object will interpolate the code | ||
| 37 | and message into a single string in the format "Message [Code]". | ||
| 38 | |||
| 39 | =head1 SEE ALSO | ||
| 40 | |||
| 41 | L<VM::EC2> | ||
| 42 | L<VM::EC2::Generic> | ||
| 43 | |||
| 44 | =head1 AUTHOR | ||
| 45 | |||
| 46 | Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||
| 47 | |||
| 48 | Copyright (c) 2011 Ontario Institute for Cancer Research | ||
| 49 | |||
| 50 | This package and its accompanying libraries is free software; you can | ||
| 51 | redistribute it and/or modify it under the terms of the GPL (either | ||
| 52 | version 1, or at your option, any later version) or the Artistic | ||
| 53 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||
| 54 | please see DISCLAIMER.txt for disclaimers of warranty. | ||
| 55 | |||
| 56 | =cut | ||
| 57 | |||
| 58 | 7 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 59 | 7 | ▶ | use base 'VM::EC2::Generic'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 60 | |||
| 61 | use overload | ||
| 62 | '""' => sub { | ||
| 63 | 0 | ▶ | my $self = shift; |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 64 | 0 | my $msg = $self->Message; | |
| 65 | 0 | $msg =~ s/\.$//; | |
| 66 | 0 | my $code = $self->Code; | |
| 67 | 0 | return "[$code] $msg";}, | |
| 68 | 7 | ▶ | fallback => 1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 69 | |||
| 70 | sub valid_fields { | ||
| 71 | 0 | ▶ | my $self = shift; |
|
Subroutine
valid_fields: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 72 | 0 | return qw(Code Message); | |
| 73 | } | ||
| 74 | |||
| 75 | # because the darn Error XML doesn't adhere | ||
| 76 | # to the conventions elsewhere, in which | ||
| 77 | # the initial letter of the tag is lowercase | ||
| 78 | 0 | ▶ | sub code {shift->payload->{Code}} |
|
Subroutine
code: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 79 | 0 | ▶ | sub message {shift->payload->{Message}} |
|
Subroutine
message: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 80 | |||
| 81 | 7 | 1; | |