NAME

WebService::GData::Error - create an error and parse errors from Google data APIs v2.

VERSION

0.01

SYNOPSIS

	use WebService::GData::Error;

    #create an error object that you can throw by dying...
   	my $error = new WebService::GData::Error(401,'Unauthorized');
	# $error->code;
	# $error->content;
	#die $error;

    #create an error object in response to a Google Service.
   	my $error = new WebService::GData::Error(401,$responseFromAService);
	print $error->code;
	print $error->content;#raw xml content

	my @errors = $error->errors;#send back WebService::GData::Error::Entry objects

	foreach my $error (@{$error->errors}){
			print $error->code;
			print $error->internalreason;
			print $error->domain;
			print $error->location->{type};#this is just a hash
			print $error->location->{content};#this is just a hash
	}

DESCRIPTION

inherits from WebService::GData;

This package can parse error response from Google APIs service. You can also create your own basic error.

All WebService::GData::* classes die a WebService::GData::Error object when something went wrong.

You should use an eval {}; block to catch the error.

Example:

    use WebService::GData::Base;


    my $base = new WebService::GData::Base();
	eval {
	   $base->get($url);

	};
	#$error is a WebService::GData::Error;
	if(my $error=$@){
		#error->code,$error->content, $error->errors
	}

METHODS

new (code:Int,content:Scalar)

    Accept two parameters: a code number (ie,a http status code) and a string.

    The string can be a Google xml error response, in which case, it will parse the contents and give you access to it via errors() method.

code

    Get back the error code.

content

    Get back the raw content of the error.

    When getting an error from querying one of Google data services, you will get an xml response containing possible errors.

    In such case,you should loop through the result of errors() which send back WebService::GData::Error::Entry.

errors

    Get back a reference array filled with WebService::GData::Error::Entry.

    When getting an error from querying one of Google data services, you will get an xml response containing possible errors.

    In such case,you should loop through the result of errors() which send back WebService::GData::Error::Entry.

    errors allways send back a reference array (even if there is no error).

    Example:

    my @errors = $error->errors;#send back WebService::GData::Error::Entry objects
    
    foreach my $error (@{$error->errors}){
    		print $error->code;
    		print $error->internalreason;
    		print $error->domain;
    		print $error->location->{type};#this is just a hash
    		print $error->location->{content};#this is just a hash
    }

CONFIGURATION AND ENVIRONMENT

none

DEPENDENCIES

JSON

LWP

INCOMPATIBILITIES

none

BUGS AND LIMITATIONS

If you do me the favor to _use_ this module and find a bug, please email me i will try to do my best to fix it (patches welcome)!

AUTHOR

shiriru <shiriru0111[arobas]hotmail.com>

LICENSE AND COPYRIGHT

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

4 POD Errors

The following errors were encountered while parsing the POD:

Around line 124:

You forgot a '=back' before '=head2'

Around line 130:

You forgot a '=back' before '=head2'

Around line 141:

You forgot a '=back' before '=head2'

Around line 165:

You forgot a '=back' before '=head1'