Changeset 1345

Show
Ignore:
Timestamp:
11/12/07 23:31:28 (7 years ago)
Author:
tokuhirom
Message:

Net-Wassr: more strict argument check.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Net-Wassr/trunk/lib/Net/Wassr.pm

    r1293 r1345  
    55use JSON::Any; 
    66use Encode; 
     7use Carp; 
    78 
    89our $VERSION = '0.02'; 
     10our $DEBUG = 0; 
    911 
    1012sub new { 
     
    5052sub update { 
    5153    my ( $self, $args ) = @_; 
     54    croak "args required hashref" unless ref $args; 
    5255    my $encode = delete $args->{encode}; 
    5356    $encode         ||= 'utf8'; 
     
    6063    my ( $self, $api, $args ) = @_; 
    6164 
    62     my $req = $self->{ua}->post( $self->{apiurl} . $api, content => $args, ); 
    63     return $req->is_success ? JSON::Any->jsonToObj( $req->content ) : undef; 
     65    my $res = $self->{ua}->post( $self->{apiurl} . $api, content => $args, ); 
     66    if ($Net::Wassr::DEBUG && !$res->is_success) { 
     67        die $res->status_line; 
     68    } 
     69    return $res->is_success ? JSON::Any->jsonToObj( $res->content ) : undef; 
    6470} 
    6571