tagomoris / Net-Hadoop-WebHDFS

Other
2 stars 3 forks source link

Please do not die on errors #6

Open martinthurn opened 9 years ago

martinthurn commented 9 years ago

Some (most? all?) of the methods die if there is an error. For example, try to append onto a file that does not exist. Please DO NOT DIE on errors, that's what the return value of Boolean is for!

tagomoris commented 9 years ago

Dying is not in my design. Is it contain messages like NameNode returns non-redirection (or without location header)? If so, it is bug. Please show me dying message.

martinthurn commented 9 years ago

You are calling croak, which is the same as die. Instead of calling croak, you should save the error message somewhere and return 0, I think.

tagomoris commented 9 years ago

Calling croak is under my decision. But it is abnormal situation, and I need to know what situation makes such case. Please tell me whether dying message is Namenode returns non-redirection or not.

martinthurn commented 9 years ago

For example, call stat() on a file that does not exist.

my $rh = $o->stat(q{/no/such/file}); print "after the stat call\n";

This code dies with a JSON error (see below), it never prints "after the stat call" and I have no chance of doing anything if the file does not exist.

FileNotFoundError: {"RemoteException":{"message":"File does not exist: \/no\/such\/file","exception":"FileNotFoundException","javaClassName":" java.io.FileNotFoundException"}} at hdfs-loader.pl line 105

On Sun, Mar 1, 2015 at 9:07 AM, TAGOMORI Satoshi notifications@github.com wrote:

Calling croak is under my decision. But it is abnormal situation, and I need to know what situation makes such case. Please tell me whether dying message is Namenode returns non-redirection or not.

— Reply to this email directly or view it on GitHub https://github.com/tagomoris/Net-Hadoop-WebHDFS/issues/6#issuecomment-76598116 .

tagomoris commented 9 years ago

I've just added suppress_errors option to client at master:HEAD.

my $client = Net::Hadoop::WebHDFS->new(..., suppress_errors => 1);
unless ($client->stat(q{/no/such/file})) {
  say $client->{last_error};
}

Can you test it?